question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
I am trying to create a custom Recent Posts widget that accepts a category, to show only posts in that category. I'm having trouble saving the widget options. I've done some debugging and found that in the update function, <code> $new_instance </code> only contains the title options and not via_cat. Here's the code for...
Your problem is that you're calling the wrong method for generating the name attribute. It should be <code> $this-&gt;get_field_name('via_cat') </code> Also, you can use <code> wp_dropdown_categories() </code> , no need to reinvent the wheel: <code> wp_dropdown_categories(array( 'name' =&gt; $this-&gt;get_field_name('v...
Widget Options Not saving
wordpress
I get a blank page on /wp-admin/edit.php after change the number of post to display. The bug is due to the PHP memory, but on my hosting I have no possibility to change this value. How to reset the number of post to display on the edit.php page please. Thanks you
In your usermeta database table, there will be rows containing a meta_key of <code> edit_post_per_page </code> find the row that matches your username and then either change the value to something more sensible, or delete that row to restore the default of 20. Or you could delete all rows in that table with that key, i...
Blank page for edit.php
wordpress
Is there a WP plugin to show the number of drafts in the Posts section of the admin sidebar in the same way that the number of available updates is shown? I’m looking for something like the following example:
I found Quick Review Post Access (Figure 1) which does the trick. It’s not perfect; I was hoping for the little circle, but this works just as well, and even better, it links directly to the page with non-drafts filtered out, making it even easier to keep track of and work with incomplete posts. It even works for pendi...
Displaying number of drafts in Posts section of admin sidebar
wordpress
For whatever reason, I have a post and a page with the same slug name and it causes the db to hang. I can't alter the slug on either so I need to go manually delete the posts from the database and start over. Now, I am willing to go pull up the post ID from wp_posts and wp_postmeta and manually delete each entry. Will ...
Drop this into a file in your plugin directory and you should be able to do this from your WP installation using a query string. <code> /* Plugin Name: Delete Specific Post Description: Rid the post forever! Version: 0.1 Author: WPSE License: GPL2 */ add_filter('query_vars', 'delete_post_query_var'); function delete_po...
Manually delete post from database
wordpress
I've inherited webmaster tasks for a site re-design that involves heavy use of widgets. On the frontpage, two videos are loading in two text widgets, and they play fine once loaded. The problem is that on first load of the page, the video that uses <code> &lt;embed /&gt; </code> loads randomly up by the top left hand c...
I tried Chrome, IE9 and IE8 all without a problem and even on a slow Starbucks connection. But it might help to give height and width attributes to all the images above to prevent the page from cascading. The second problem (i.e. the object jumping during scroll) I think is simply an IE rendering flaw - not really a bu...
iframe/embed vid in text widget loads outside container and moves around when scrolling the page?
wordpress
I like wordpress as a CMS and I think it's got a lot there with it's vast plugin library however the front end, dare I say it is a bit out of date. I don't like the system of old going page-to-page and would prefer a single-page site powered by JSON/AJAX. I've used wordpress to make simple client sites but when it come...
There's nothing stopping you using AJAX for a singlepage website that loads in other pages dynamically rather than going to a whole new page. I would advise you build the site without the AJAX and then add AJAX on top so that everything degrades gracefully should an error occur or if javascript is turned off. So assumi...
single page wordpress
wordpress
Precondition: coming from a Custom PHP applications(using symfony, zend and so on) world, for me it feels unnatural to have template separated in a way that is done in original wordpress theme. e.g top part of a page is in header, center in a "index, page..." and bottom part in a footer. example of current structure: i...
First, as @Toscho implies, the <code> get_header() </code> and <code> get_footer() </code> template tags simply include files named <code> header.php </code> and <code> footer.php </code> , respectively. Both template tags are called from within template files, and you can separate content between template file ( <code...
What are the ADVANTAGES of ORIGINAL wordpress template structure?
wordpress
I have a hostgator wordpress site. My friend wrote two small php scripts to help us with a medial task we do a lot in our work, but he is currently hosting this script on his server; I want to host it on our official server. Is there a way to straight-up ftp this folder containing two php files a larger js file a subfo...
WordPress offers a dedicated API for your need: the Plugin API . So (let) write a plugin, which is really easy. Then you can use the extra code probably without conflicts.
running arbitrary php files
wordpress
this is my first question about wordpress, because i don't know much about wordpress. i have installed AntiSpam bee in my wordpress blog. And i got comments which marked as spam with the reason <code> Server IP </code> , that i got first time. But i got shocked when i see that the comment don't had any Email Address . ...
You get this if <code> $_SERVER['REMOTE_ADDR'] </code> of a ping/track back doesn’t match the IP address of the URL the ping back comes from allegedly. Let’s say someone claims to send a ping back from <code> example.com </code> but the request IP and the server IP for <code> example.com </code> are different – the pin...
What is the server IP comment hack
wordpress
Is is possible to create an alphabetical search like so: A | B | C | D | etc Each letter is a link so when clicked it would show all the posts starting with "A" or "B" etc etc. If so, how could I do it?
Yes. Do a SQL query for posts using <code> LIKE 'x%' </code> , where <code> x </code> is your letter. Here's a simple example: <code> global $wpdb, $post; $letter = 'a'; // or $_GET['letter']... $query = "SELECT * FROM {$wpdb-&gt;posts} WHERE post_name LIKE %s"; $query = $wpdb-&gt;prepare($query, $letter.'%'); $results...
Alphabetical search
wordpress
I'd like to create a permalink structure that works in the following way: Pages - http://myurl.com/ pagename Posts - http://myurl.com/news/ postname / How would I do so? Thank you
Go to "Settings" -> "Permalink" page and set custom structure for permalinks equals to <code> /news/%postname% </code> .
Custom Permalink Structure for Pages & Posts
wordpress
I have a custom post type "projects" with a custom taxonomy "project_type." If I select a project type taxonomy within the post editor screen and hit update, the taxonomy isn't updated. Worse yet, it clears all taxonomy values associated with that project. Oddly, I added a column in the admin screen to display the cust...
If you have a custom post type and a custom taxonomy assigned to it, you do not need to handle the saving of those terms yourself, WordPress already does this for you. So you can remove your taxonomy save code. Also you should put your register_post_type and custom taxonomy registering code inside a function, and attac...
Custom Post Custom Taxonomy Data Not Saving in Edit Screen
wordpress
I'm not really sure how to phrase the questions, but hope it's not too confusing. Basically I've create a plugin which inject custom tabs into the posts content when displaying. For now, just assume I'm using DomTab , and I have permalink configured as <code> /%category%/%postname%/ </code> . Now I would like achieve 2...
I've found out the solutions, though not perfect, but it gets the job done. Following is the code <code> add_action('init', 'my_init'); function project_ace2_init() { global $wp; $wp-&gt;add_query_var('tab'); // Needed so get_query_var('tab') will work add_rewrite_rule( //'(.+?)/([^/]+)(/([^/]+))?/?$', //Original : '(....
How to use permalink query to go to specific tabs in posts
wordpress
At the moment I am doing something like the following from inside the main loop; <code> $custom_values = get_post_custom_values('tenderfields'); $custom_values = unserialize($custom_values[0]); $custom_values = $custom_values[0]; </code> Then accessing them with <code> $custom_values['my-custom-value'] </code> This wor...
If you always need all of post meta at once this is the way to do it. To access post meta for specific key use <code> get_post_meta() </code> that will retrieve value(s) and unserialize if needed.
What is the cleanest way to extract custom variables from a post
wordpress
When I create a new page, I want these two checkboxes (from the "Discussion" meta box) to appear unchecked by default. Can this be done programmatically?
You can re-register the "page" post type and leave out the comments capability. <code> add_action( 'init', 'my_new_page_type' ); function my_new_page_type() { register_post_type( 'page', array( 'labels' =&gt; array( 'name_admin_bar' =&gt; _x( 'Page', 'add new on admin bar' ), ), 'public' =&gt; true, 'publicly_queryable...
"Discussion" checkboxes unchecked by default on pages?
wordpress
I need a conditional to check to whether or not to execute code at the top level of network admin pages: <code> /wp-admin/network </code>
<code> if(is_super_admin() &amp;&amp; is_network_admin()){ // do network admin only code } </code> http://codex.wordpress.org/Function_Reference/is_super_admin http://hitchhackerguide.com/2011/02/24/is_network_admin/
Function to check whether the user is at the top level of the network?
wordpress
I am importing a large DB from an Excel spreadsheet into a wordpress DB. I was going to do it manually by creating a new table but decided to import it into the existing wordpress framework as it will allow me to change information manually in the wordpress back end. I was importing all 2000 rows into the wp_posts tabl...
I don't think you should create a new column in wp_posts... This kind of info is stored in wp_postmeta. When I need this kind of importing (Excel-> WP), I use CSV Importer , as you can assign categories, tags and custom field to the imported data. You'll probably need to do a couple of tests with few entries until get ...
Importing data from spreadsheet into wordpress DB, along with custom taxonomies and their terms
wordpress
I'm trying to block any admin of a Wordpress install from being able to modify certain pages, the sort of stuff detailed here: http://wackao.com/be-a-wordpress-super-administrator/ . Is this even possible? Thank you. I would like to do this by modifying the core word press files.
I would recommend creating a Custom User Role , using the <code> add_role() </code> function, such as a " Site Admin " or " Sub-Admin " (or whatever you want to call it). Then, you can assign specific user capabilities to that custom role, thereby giving users exactly the capabilities you want them to have, without giv...
Wordpress Super Admin
wordpress
Is it possible to reference a class instead of a function in 'add_action'? Can't seem to figure it out. Here is just a basic example of the function in question. <code> add_action( 'admin_init', 'MyClass' ); class MyClass { function __construct() { .. This is where stuff gets done .. } } </code> So yeah, that doesn't w...
No, you cannot 'initialise' or instantiate the class through a hook, not directly. Some additional code is always required ( and it is not a desirable thing to be able to do that, as you're opening a can of worms for yourself. Here is a better way of doing it: <code> class MyClass { function __construct() { add_action(...
add_action reference a class
wordpress
This code is used to get the directory of the current plugin: <code> plugin_dir_url( __FILE__ ) </code> . What should I use to get the directory of the current theme?
I think you have to be a little careful because it depends on what you are trying to do. If you are using a child theme get_template_directory(); will still go to the parent theme. However get_stylesheet_directory(); will go to the current theme, child or parent. Also, both these functions return absolute server paths....
How to get the path to the current theme?
wordpress
I'm trying to find away to retrive a dynamic sidebar from one blog and print it on another blog in the same install of Wordpress Multisite. I have tried <code> switch_to_blog($blog_id); dynamic_sidebar($sidebar_name); restore_current_blog(); </code> But nothing is returned. I also tired to retrive the sidebar through <...
Unfortunately, the <code> switch_to_blog() </code> method isn't going to work for this purpose. <code> switch_to_blog() </code> is really only a partial switch - it makes some modifications to <code> $wpdb </code> that help with database queries. But it's not a complete switch in the way you might imagine. In particula...
Sharing Dynamic Sidebars across Multisite Blogs
wordpress
I'm developing a plugin. This plugin creating a new post type and displaying these posts in a custom template. For example it's a event calendar plugin. This plugin creating a new post type 'event '. Users adding new events from wp - admin, like normal blog posts. And users creating a new page with 'Event Calendar ' pa...
I second Tom's answer, however in the interest of answering your question, have a look at stackexchange-url ("this question") using the <code> template_include </code> filter.
Using custom page templates with plugin
wordpress
What is the difference, which one should I use? I know that wp_verify_nonce checks the time limit, and check_admin_referer I think calls wp_verify_nonce as well as checking for an admin url segment, but I'm a bit confused on which one I should use and when. Thanks for the clarity.
I thought that <code> check_admin_referer </code> checked the nonce (it does call <code> wp_verify_nonce </code> , and the referring url. After digging into the core code I realised that it did not do this. Thinking it was a bug I reported it, and Ryan Boren replied with the following: Actually, if the nonce is valid t...
wp_verify_nonce vs check_admin_referer
wordpress
I am having a strange side effect since going to 3.3.1. When updating pages (or creating new ones) all of my permalinks break - clicking view page on the updated page in question will result in 404 not found. This does not happen with posts. I was concerned it might be an issue with my new schema for permalinks /%postn...
I had tested it with all plugins off, and just as I was about to swap to 2011 I looked over all my custom taxonomies, which I coincidentally added around the 3.2.1 update. Lo and behold - I had foolishly added a 'year' taxonomy, changing that to 'show-year' seems to have licked it. Foolish mistake, thanks for the inter...
Update page breaks permalinks
wordpress
Let me start by saying, I am not a coder, but enjoy learning. Here is the situation. I have many custom profile fields for social media added to my user profiles. The user enters the full URL of their profile, then their information is displayed on their author page with their bio, profile image, all posts, etc. I also...
You need to do this in steps: Decide when you are going to parse the user's meta to change the value. Define a function to do that. Hook that function to the appropriate action. The original answer defined what you need to do for step #2, using <code> preg_match() </code> to parse the Twitter URL and extract the userna...
Strip Twitter Username from Profile Field with URL and Save to New Profile Field
wordpress
Below is the current loop I have setup: <code> &lt;?php //start products category loop $args = array( 'hide_empty' =&gt; 0, 'parent' =&gt; 0, 'orderby' =&gt; 'name', 'order' =&gt; 'ASC', 'taxonomy' =&gt; 'profile_categories', 'pad_counts' =&gt; 1 ); $categories = get_categories($args); foreach($categories as $category)...
This is potentially a bug* - but it doesn't seem like it is the same one you have linked to. The problem lies in the <code> get_terms </code> function. Specifically here: http://core.trac.wordpress.org/browser/trunk/wp-includes/taxonomy.php#L1397 The array of terms (which when <code> parent=0 </code> , are are just the...
Category 'pad_counts' & 'parent' conflict
wordpress
I have a <code> mymail.php </code> script which sends a email (I managed to do it using <code> require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-includes/class-phpmailer.php' ); </code> .) and outputs a plain text string (Such as "Email is sent successfully.") I want to use the functions defined in WP in this my script. T...
Put this near the top of your PHP file: <code> require_once('wp-blog-header.php'); </code> You may also want to reduce wordpress core load by defining SHORT_INIT, though this depends on which functions you are using ( and wether they get loaded when this is defined ). But this is completely the wrong way of going about...
How to load WP functions?
wordpress
When I upload an image, it is automatically resized as I would expect, however the sizes for inserting the image seem to ignore the settings I've placed in Settings/Media. In my media settings I have: Thumbnail: 150 x 150 Medium: 300 x 300 Large: 690 x 9999 I upload an image of: 2226 x 1663 . Wordpress generates the co...
I believe your issue is that the value set for the global <code> $content_width </code> variable (which is 640px in Boilerplate and 584px in Twenty Eleven) is less than the width you're specifying via <code> Settings -&gt; Media </code> . WordPress is overriding your user setting with the Theme-specific value. This act...
Settings in 'Media > Settings' is ignored when inserting images
wordpress
I have a metabox on my post type of 'ebrd_videos' that sets the video as a 'featured video' using a checkbox. I would like to limit the number of videos with the status of 'featured = on' to 1. So that when I set a video as featured, and publish/update that video, all other videos are set to 'featured = off'. If it hel...
If you really want to have only one post id and a value attached to it, well i think it will be better to store in options table using add_option and then using it using get_option..... that way you will be saved from headache of updating all posts meta at once when any of post is updated.....
How can I set a meta value that will then affect other post meta values?
wordpress
How does one create a post, assign it to a category, add tags to it and set the featured image from a PHP script that exists somewhere on disk (say /usr/local/process.php) and isn't part of the Wordpress installation or infrastructure? I searched for a couple of hours and can't find anything particularly useful. The on...
You can remotely create posts programmatically via XML-RPC e.g. PHP http://www.nickycakes.com/post-to-wordpress-remotely-with-xmlrpc-in-php/ Java http://code.google.com/p/wordpress-java/ Of note, the media library handles image EXIF data etc, it might be more convenient to switch from using posts to just displaying the...
How does one programmatically manage posts from a external php script?
wordpress
This is probably a really noob question, but I can't figure out how to change it. I've created a page called "Photos" and my url link shows: <code> http://mysite.com/photo-7/ </code> What's with the -7 and how do I remove this so it is just photo ?
This is because your site already has a post or page (6 in your case) with the slug "photo." They might be in the trash, or pending as drafts, or whatever ... but WordPress automatically appends number to prevent name conflicts. So go through your site, and figure out which other pages are trying to use the "photo" slu...
Clean URL link for page without number
wordpress
I've looked everywhere for a solution, but have yet to find one. Here is the situation. I've created a custom content type using the plugin <code> Custom Content Type Manager </code> and now have need to use these custom post types within pages that I've created in WP. So I created a page called "Photos" and use a temp...
The loop in your code is automatically going to pull data from the current page ID (i.e. Photos). You have to define the query for which data you're looking for. Be sure to replace <code> photo </code> with whatever the slug is for your post type. See http://codex.wordpress.org/Class_Reference/WP_Query for other argume...
Pull in custom content types into page template
wordpress
I'm using SimpleModal to allow users to click on a post excerpt on my homepage and popup a box showing the full post. However it doesn't count for an actual view of the post when this happens. Is there a way to make wordpress recognize it as a view? I'm using wp-postviews to track view counts.
Apparently the plugin does the logging inside the <code> wp_head </code> hook: <code> add_action('wp_head', 'process_postviews'); </code> so make sure you call <code> wp_head() </code> in your pop-up box, or if you can't do that (pop-up is not a html document), then just call the function directly, like: <code> if(func...
Make view count for pop up post
wordpress
I uploaded wordpress to my server. Everything works fine so far. But when I try to upload data to my media libary nothing happens. Doesn't matter if I click the "Select Files" or "browser uploader" just nothing happens. I never had those kind of problems before. The permission for the wp-content/uploads/ folder is on 7...
<code> function load_scripts() { wp_deregister_script('jquery'); wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js")); wp_enqueue_script('jquery'); } add_action('init', 'load_scripts'); </code> I have found the problem now (for all the following readers). In my template function...
Unable to upload data to Media Libary
wordpress
Asked this question at serverfault, and got confirmation that W3TC is most likely causing the issue, but several of my more W3TC/Wordpress specific issues weren't able to be answered. Reposting here as this community had hopefully answer those better. I emboldened them below.* AWS EC2 Small instance, Apache 2 running W...
Generally speaking your apc.shm_size should be double your highest seen used amount. You want to try and prevent your cache full count from being higher than 0. You might want to also lower some of your ttls. I'm working with someone on AWS EC2 with 5 vhosts and we had to raise apc.shm_size to 512M to prevent 100% frag...
APC fragmention woes on Apache AWS EC2 Small instance with WordPress and W3TC
wordpress
I'm working on my first wordpresss website and I've really never worked with RSS feeds. However my friend that I'm doing a website for wants it in there. so I guess I'm in a crash course learning session with google to learn all I can about RSS feeds. I was hoping to find a plugin that just allowed the visitor to subsc...
As you develop WP theme, I would mention that you need to enable automatic-feed-links by adding following function call to your functions.php file: <code> add_theme_support( 'automatic-feed-links' ); </code> After it RSS links fill be added automatically to head of your site. The best practice is to add this call in fu...
RSS feeds and wordpress?
wordpress
This is part two to this question: stackexchange-url ("Post Specific Uploader") I am using an upload filter to put files in a location based on <code> post_id </code> . Now when the file uploads, the URL path in the meta is wrong and the image preview is broken (missing the <code> post_id </code> ). the URL shows as: <...
untested, but it should work theoretically: <code> add_filter('get_attached_file', function($path, $file, $attachment_id){ // get the post object of the current attachment $att = get_post($attachment_id); // prepend attachment post parent ID to the file name return substr_replace($path, "{$att-&gt;post_parent}/{$file}"...
Image not showing up in media loader success area - followup
wordpress
I'm using wordpress multisite. I installed s2member plugin. s2member plugin creates 4 extra level. I mean like level1,level2,.... I'm displaying content using this code <code> if (current_user_can("access_s2member_level1")){ the_content(); } </code> Here level1 member is premium member. If the user is not a premium mem...
The function <code> current_user_can_for_blog() </code> seems to be what you are looking for. With your example above, this solution should work: <code> $blog_id = 1; //set the blog id to the main site id if (current_user_can_for_blog($blog_id, "access_mainsite_s2member_level1")){ the_content(); } </code>
How to check main site user level from subsite in a multisite network
wordpress
I would remove Tag capability from classic Post type, can I use <code> remove_theme_support( $feature ); </code> and how to do this ? Thanks in advance
You can do it with something like this: <code> add_action( 'init', 'wpse48017_remove_tags' ); function wpse48017_remove_tags() { global $wp_taxonomies; $tax = 'post_tag'; // this may be wrong, I never remember the names on the defaults if( taxonomy_exists( $tax ) ) unset( $wp_taxonomies[$tax] ); } </code> There was a m...
Remove Tag from theme support
wordpress
I have played around with filters for uploading files. The closest I have gotten is to have the files uploaded to the directory, but after the file uploads, I get a series of errors: <code> Undefined index: post_id </code> I think the issue is as simple as not having access to the current post id. I have tried <code> $...
Check if the argument is present, and if it isn't return the default value: <code> if(!isset($_REQUEST['post_id'])) return $upload; // cast it to integer to avoid problems $id = (int)$_REQUEST['post_id']; ... </code>
Post Specific Uploader
wordpress
I have the following action callback set up: <code> function abc_save_post($post_id, $post) { // do stuff echo '&lt;pre&gt;'.print_r($post,true).'&lt;/pre&gt;'; } add_action('save_post', 'abc_save_post', 10, 2); </code> The thing is that <code> $post </code> is a very trimmed down version of <code> $_POST </code> and i...
Simply use the post ID, provided by <code> $post_id </code> (and stored at <code> $post-&gt;ID </code> ) to use the various functions WordPress provides to get any extra data related to that post ( <code> get_the_terms </code> , <code> get_post_meta </code> etc). Performance wise you suffer no loss by using these funct...
How can I get more out of `$post` in an `add_action` callback?
wordpress
I have some html: <code> &lt;div class="container"&gt; &lt;p class="accent"&gt;The first paragraph...&lt;/p&gt; &lt;p&gt;The rest of the article...&lt;/p&gt; &lt;/div&gt; </code> I'd like to put "the_excerpt" in the first paragraph (with a special colour / font size) but then have the following text be "normal". Is the...
The key is to use user-defined excerpts , rather than auto-generated excerpts. For example: <code> &lt;div &lt;?php post_class(); ?&gt;&gt; &lt;?php // If post has defined excerpt, output it here if ( has_excerpt() ) { ?&gt; &lt;div class="first-paragraph-excerpt"&gt; &lt;?php the_excerpt(); ?&gt; &lt;/div&gt; &lt;?php...
Combining the_excerpt with the_content
wordpress
I am trying to change: <code> add_action('wp_footer','myscript_in_footer'); function myscript_in_footer(){ ?&gt; &lt;script type="text/javascript"&gt; jQuery(document).ready(function(){ jQuery("div.domTip_tipBody").mouseover(function(){ jQuery("#yyy a.tippy_link").css("background-color","yellow");}); jQuery("div.domTip...
Looks like you're missing the jQuery ready function. Try this: <code> jQuery(document).ready(function($){ $.delegate('p','mouseover', function(e){ $("#yyy a.tippy_link").css("background-color","yellow"); }); $.delegate('p','mouseout', function(e){ $("#yyy a.tippy_link").css("background-color","red"); }); }); </code> Ch...
Change jQuery(document).ready to $.delegate in wordpress
wordpress
Twitter Bootstrap have a javascript plugin called TypeAhead which is simular to Google Instant Search. I'm using it to pull the WordPress post titles into the search box, using the following code c/o @StephenHarris <code> data-source='[&lt;?php $posts = get_posts( array( 'numberposts' =&gt; -1, 'category' =&gt; 0 ) ); ...
As @OneTrickPoney points out, there's an alternative in core. jQuery UI autocomplete comes with WP default install. Autocomplete, when added to an input field, enables users to quickly find and select from a pre-populated list of values as they type, leveraging searching and filtering. By giving an Autocomplete field f...
Link permalink in Twitter Bootstrap "TypeAhead" results
wordpress
I would like to understand how does twenty eleven title page no works.. sprintf( __( 'Page %s', 'twentyten' ), max( $paged, $page ) ); I dont understand the above part as in the __() function the arguments are $text and $domain what is $domain and how does %s print's no. Below is the whole code of title thank you <code...
OK, so... <code> sprintf( __( 'Page %s', 'twentyten' ), max( $paged, $page ) ); </code> First off - sprintf . Returns a <code> formatted string </code> , using variables and a type specifier to display information. For example, <code> $house = "Mansion"; $house_number = 49; sprintf( 'My house is a %s and its number is ...
Title how does page no work in Twenty Eleven
wordpress
I need to list post_title's in this specific format (note the last title in the list must not have a comma) <code> "post_title","post_title","post_title" </code> I thought a mini-loop might work. Here's what I'm using <code> &lt;?php query_posts('cat=0$posts_per_page=-1'); // query to show all posts independant from wh...
I'm not sure of the context for this, but <code> query_posts </code> probably isn't what you want to use. (See stackexchange-url ("this answer")). ( Untested ). I would use get_posts: <code> $posts = get_posts(array( 'numberposts'=&gt;-1, 'category'=&gt;0 )); </code> And then use <code> wp_list_pluck </code> to get the...
How to Loop with the final result formatted differently?
wordpress
I am having a problem with the <code> the_excerpt(); </code> tag which I am using in my own theme in the index.php and archive.php files. The code is below: index.php <code> &lt;?php get_header(); ?&gt; &lt;section class="center-column"&gt; &lt;?php if (have_posts()) : ?&gt; &lt;?php while (have_posts()) : the_post(); ...
Thank you for all your help, especially @byronyasgur for your last suggestion. It helped me fix it. I was using markdown as the input format for the content, and the first line was HTML comment which was not followed by a blank line. Adding a blank line fixed it. Summary: The absence of this line caused the excerpt to ...
the_excerpt(); tag not working
wordpress
I've been trying to use numerous jQuery plugins for tabling sorting in WordPress and have had absolutely no luck. Can anyone make a suggestion for a plugin that sorts tables of dynamic content? I'm using the following code to generate the table: <code> $args=array( 'post_type' =&gt; 'page', 'post_status' =&gt; 'publish...
You might try calling the table by ID instead of the generic 'table'. Also, wrap your JS in a noconflict wrapper like this: <code> (function($) { $js162(function(){ $js162("#actArchive").tablesorter({ headers: { 0: { sorter: "text" }, 1: { sorter: "digit" }, 2: { sorter: false }, 3: { sorter: false } } }); }); })(jQuer...
Sorting dynamic table content with jQuery
wordpress
I've got my blog setup on a subpage (not the front page) and I'm using the template file <code> home.php </code> , how can I get the contents from the page editor onto this subpage? If I change the title of the page it changes in the nav menu, but how can I get this to display on the page? (i.e. as the <code> &lt;h1&gt...
Untested, but try: <code> &lt;?php echo get_the_title( get_option( 'page_for_posts' ) ); ?&gt; </code> But it's somewhat hackish. Really, the <code> page_on_front </code> and <code> page_for_posts </code> are intended to be nothing more than placeholders for the site front page and blog posts index page.
I put my blog on a subpage, how do I get page title?
wordpress
i am trying to insert a post/page into one of my themes files and it wont display shortcodes or php i have created a page called home in the wordpress admin-paned and inserted into my code the following: <code> &lt;div id="home_page"&gt; &lt;!-- echos the content from the page "home" id:43 --&gt; &lt;?php $home_id = 43...
You need to apply the filter <code> the_content </code> e.g.: <code> &lt;?php echo apply_filters('the_content',$home_page-&gt;post_content); ?&gt; </code> Also, you don't need custom shortcodes for youtube, just put the URL in the content (but not a hyperlink), and it'll be swapped out for a youtube player at runtime. ...
post/page content
wordpress
I'm writing a protected-page plugin and want to disable comments on protected pages. I'm usually hooking into <code> the_content </code> but that's not enough for comments. I got into <code> comments_array </code> to block the existing comments, but how do I block <code> comments_template </code> ?
You can control whether comments appear by filtering the <code> comments_open() </code> function. Here is an example from the WordPress codex: <code> add_filter( 'comments_open', 'my_comments_open', 10, 2 ); function my_comments_open( $open, $post_id ) { $post = get_post( $post_id ); if ( 'page' == $post-&gt;post_type ...
writing a plugin, how to disable the comment form altogether?
wordpress
I'm stuck in a rather simple task: to get the category title for the current post, within the loop, to be used in the function (not to be automatically printed). Any ideas?
The function <code> get_the_category() </code> returns an array of category objects. To get the name of the first category, use this: <code> $categories = get_the_category(); $cat_name = $categories[0]-&gt;cat_name; </code> For a list of the properties of the category object, see the documentation on <code> get_the_cat...
How to get post category title within the loop?
wordpress
I think the way wordpress display previous and next posts is basically non sense, with next posts on the left side, and older posts on the right side. I am using the code <code> &lt;?php posts_nav_link() ?&gt; </code> is there a way to reverse such order?
This is because it is, by default, done as 'previous page' on the left, and 'next page' on the right. Posts appear in reverse chronological order, with the latest post first, so 'next page' means going back in time. So in terms of pages it makes sense, in terms of chronology it doesn't. Anyway... this should work: <cod...
reverse next/prev page order
wordpress
I've created a custom post type and custom taxonomy (all fine so far!) but when I try to view the post it's giving me a page not found. What do I need to do to setup a template which the custom post type below will use? <code> add_action( 'init', 'create_post_type' ); function create_post_type() { register_post_type( '...
According to the WordPress template hierarchy , a custom post type 'my-cpt' will first try to use <code> single-my-cpt </code> , then <code> single.php </code> and then <code> index.php </code> . The above issue is not caused by templates - indeed 404s are used when the content, not the template, cannot be found. You a...
How to select a template for a custom post type?
wordpress
I use the following code to get the Administrator role <code> $admin = get_role('administrator'); </code> This works fine, but on a different WordPress language setup, this code breaks. For example, in French it should be <code> $admin = get_role('adminstrateur'); </code> Any cross-language solution?
Just guessing, but maybe: <code> $admin = get_role( __( 'administrator' ) ); </code> If you're trying to make sure that WP translates the string for a specific locale, <code> __() </code> will return the translated string. So if <code> get_role('administrator') </code> works and on a French setup <code> get_role('admin...
Getting a role based on a localized role name
wordpress
// Be sure to read the updates at the bottom I have a large multisite installation hosted on XAMPP on an XP 2003 server and am trying to move it from XAMPP/Apache to a new Windows 2008 server with IIS7. I can successfully get fresh installs of WP up and running and can get multisite working perfectly. When I import my ...
I worked through this problem myself with the help of a forum mod on wordpress.org . You can see the full forum post here .
Migrating WPMS from apache to IIS7 causes Database Error
wordpress
I am setting up a few sections of a website external to the core wordpress installation, but I still want to use the built in wpdb functions, and/or header files from wordpress. I follow the instructions outlined in wordpress, setting up my headers: <code> &lt;? require('../cms/wp-blog-header.php'); define('WP_USE_THEM...
Solution Found! Thanks to these guys <code> require('../cms/wp-config.php'); $wp-&gt;init(); $wp-&gt;parse_request(); $wp-&gt;query_posts(); $wp-&gt;register_globals(); </code> The key is, don't use wp-blog-header, but this code instead.
external wordpress pages using wp-blog-header
wordpress
I am trying out the Q&amp;A lite plugin from WPMU . It looks great except for one thing. It looks like users can only ask and answer question, not make comments on them. This effectively makes a conversation between two users very short. One question, one answer, that's it, excepting answers from other users of course,...
We had a stackexchange-url ("similar question") which received a nice amount of answers and the main issue with the plugin you linked was that it had no comments for the questions and answers and if you look at the comments you will see that both types (questions and answers) support comments you only need to display t...
Q&A lite plugin comments
wordpress
I imagine that this would be a breeze for some - but I'm having difficulty getting just the upload's directory name - not the full path - I've gotten this far: <code> $uploads = wp_upload_dir(); $upload_path = $uploads['baseurl']; // now how to get just the directory name? </code> anyone have any ideas? thanks for shar...
This is what you get back from the function: <code> Array ( [path] =&gt; C:\development\xampp\htdocs\example.com/content/uploads/2012/04 [url] =&gt; http://example.com/content/uploads/2012/04 [subdir] =&gt; /2012/04 [basedir] =&gt; C:\~\example.com/content/uploads [baseurl] =&gt; http://example.com/content/uploads [err...
wp_upload_dir how to get just the directory name .
wordpress
I want to give the option to filter the index page and every archive page for a category by things like newest, top-rated, most-viewed. I know how to filter a loop for each of those but I need a solution for switching to each filtered loop.
I would recommend defining a query var to define your custom filters, and then pass the (sanitized) value of that query var to <code> query_posts() </code> (to alter the primary Loop, if that is your ojbective). First (in <code> functions.php </code> ), define your query var: <code> &lt;?php function wpse47974_queryvar...
Allow filtering of loops for all categories
wordpress
@scribu opened a core trac ticket here for Proper Network Activation problem in multisite. It seems like its fixed in wp 3.1. But scribu was saying it doesn't fixed in wp 3.1. So he released a plugin for proper network activation . I'm using wordpress multisite. So can anyone tell me whether this problem fixed in wp3.3...
In short: No, it hasn't been fixed - You should use the plugin instead. In Detail: Activation hooks should work for the main site properly. For subsites (or as Nacin pointed out: for all sites), you should use a proper upgrade routine. Not that I double that 1) . 1) Note to myself: When a core dev says that core intern...
Proper Network Activation problem has been fixed in wp 3.3.1 or not?
wordpress
By default wp_list_pages spits out an unordered list of post titles. To save space in a sidebar menu I´m trying to create a list of page slugs instead of page titles. I suppose I´ll need to write a custom walker.. I was hoping someone can help me with an easier solution or a code snippet.
I would recommend using <code> get_pages() </code> rather than <code> wp_list_pages() </code> for this purpose. The <code> get_pages() </code> function will return an array of objects of Pages, and you can use the array data to build your own HTML list. e.g.: <code> &lt;?php // Wrap in a function, for later output; fun...
Make wp_list_pages print slugs instead of titles
wordpress
I have categories driven site. I have different template for each category. I would like to set different number of posts – different for each category . Plus I would like to add proper previous and next links in each category. for example in this <code> category-1.php </code> I want 4 posts per page: <code> &lt;?php q...
As stackexchange-url ("@StephenHarris pointed out") there's also the <code> pre_get_posts </code> filter . <code> function hwl_home_pagesize( $query ) { if ( is_category( 9 ) ) { // If you want "posts per page" $query-&gt;query_vars['posts_per_page'] = 1; return; } if ( is_category( 'movie' ) ) { // If you want "showpo...
Different number of posts in each category
wordpress
My site has several different kinds of post types. One of these is Discussions. The site is completely open and public, but my client has asked that I provide a space where only certain members can have discussions/post comments. Basically, I want only members/authors/editors/whoevers of my site to see/post new Discuss...
Template Tags for the rescue Only logged in users: <code> is_user_logged_in() </code> Only logged in users that have a certain capability assigned to their role <code> current_user_can($capability) </code> Only logged in users that have a specific role assigned <code> current_user_has_role($role) </code> Only logged in...
Easiest way to have closed comments on a custom post type
wordpress
I run a site with about 30 authors and 3 editors. Authors submit posts for review, and editors schedule or publish them. It would be useful to have another post status of "Editing" between Pending Review and Scheduled/Published. I realize there's a warning when someone else is editing a post, and that's probably signif...
I recommend you install the Editflow plugin, it lets you add arbitrary post statuses so that you can customise your workflow as you wish http://editflow.org/
Add a new post status in the post progression
wordpress
I'm fairly new to writing wordpress plugins, but I've jumped in the deep end already and I want to make sure I'm doing it "right" on my upcoming big project. I'm going to be heavily extending wordpress into a pretty big web app and want to keep my data structures as native as possible to rely on the wordpress framework...
You should be skeptical of anyone who says that there is a single "right" way. The right way depends on the situation. Using the CPT infrastructure has a number of notable benefits: You get the Dashboard UI for free You automatically take advantage of WP's caching, including any persistent cache plugins that the instal...
Should I use custom post types or a custom database tables for plugin development?
wordpress
i am building a website where the frontend users can register and they need to have custom profile pages - not the standard WordPress backend pages that the admin sees. There they can see their profile (image, name, email, ...) and change it, as well as some site specific pages like: statistics, severals lists, ... . i...
Have you tried using BuddyPress? BuddyPress allows all these thing, and has many other features ( though things can be turned on and off if it's too much )
frontend user with custom profile pages
wordpress
I have a custom content type of <code> photo_group </code> which is a collection of photos. I want to be able to go to <code> mysite.com/photos </code> and have that page dump out all of my photo groups. How can I do this without making a "page" and setting the template? Or is that the approach I'll have to take? Thank...
Romes, The method you suggested will definitely work and is likely the easiest; however, I can definitely see cases in which this is not ideal. To accomplish this more "programmatically", you would need to do the following: 1) Set a new query var 2) Generate a new rewrite rule to make sense of that query var 3) Redirec...
Clean URL permalink for custom post type
wordpress
I have created several custom content types. My question: What about showing things of different content types in search.php? Are different post types shown in search.php? if not how to make them shown? How should I configure the search code in order to show these content types which I want to show?
By default it is usually <code> post </code> s and <code> page </code> s, but, you can modify this several ways URLs <code> example.com/?s=test </code> will search for the term test in posts and pages, but, <code> example.com/?s=test&amp;post_type=product </code> will search posts of the type <code> product </code> for...
What content types are shown at a search page?
wordpress
As my question suggests I'm having difficulty creating a variable in the header, via functions.php and wp_head, and then calling that variable further down the page. For example, in functions.php <code> add_action( 'wp_footer', 'add_ran_var' ); function add_ran_var () { $random_variable = "1"; } </code> And before the ...
Before you use your <code> $random_variable </code> for the first time you need to globalize it , something like: <code> global $random_variable; </code> then next time or any time you want to access it just call globalize it again and it will be available like this: <code> global $random_variable; //do stuff with it <...
Passing a variable via wp_head and then calling it on the page
wordpress
Is there a plugin available that will automatically post an excerpt of a blog post (perhaps up to the more tag) to specified social media groups/pages. So, for example, on posting an excerpt would be posted with a 'Read more' link to a user-defined Facebook group, G+ page and, possibly, twitter feed? If not, is there a...
Search for plugins: http://wordpress.org/extend/plugins/simple-twitter-connect/ and http://wordpress.org/extend/plugins/simple-facebook-connect/ and http://wordpress.org/extend/plugins/simple-google-connect/ All require applications be built at each service for different levels of interaction with a Wordpress site, inc...
Is it possible to integrate Wordpress *posts* and social media (Facebook, Google+, Twitter)?
wordpress
As of now i'm using this code to echo user's profile url. <code> &lt;?php echo esc_url( home_url( '/' ) ); ?&gt;user/&lt;?php echo $current_user-&gt;user_login ?&gt;"&gt;&lt;?php echo $current_user-&gt;user_login ?&gt;&lt;/a&gt; </code> This link uses author base as "user". So when i change author base this link will b...
Choosing the right template As your "User Profile"-Page is something completely custom and not the admin UI user profile page, I'd suggest to take the uthor posts page instead: <code> get_author_link( true, get_current_user_id() ); </code> Then modify this template. Pretty URls No need to go outside the WP template hie...
Is there any function available to echo current user's profile url?
wordpress
Im trying to have 5 posts for page in my blog. This is what Ive used in index.php <code> &lt;?php get_header(); query_posts('posts_per_page=5'); // The Loop if (have_posts()){ while (have_posts()){ //Iterate the cursor on the next post the_post(); echo "&lt;a class='more-link' href='"; the_permalink(); echo "'&gt;&lt;h...
Ok then... try this (hope i got your request right): REVISED <code> &lt;?php get_header(); query_posts( array( 'posts_per_page' =&gt; 5, 'paged' =&gt; ( get_query_var('paged') ? get_query_var('paged') : 1 ), )); // The Loop if (have_posts()){ while (have_posts()){ //Iterate the cursor on the next post the_post(); echo ...
Link to older links
wordpress
I used the Buddypress Message Compose to send a site wide email to all members wasnt sent though. Where would I look to see why messages were not delivered to all site members of my buddypress wp site? Can I configure this to use smpt instead? I researched this some and found others have had similar problems with the "...
The way the feature works is by posting the message on the screen, not in the members inbox, and it requires the template tag: <code> &lt;?php bp_message_get_notices(); ?&gt; </code> So wherever you put the tag, the message will appear there. In the default buddypress theme, it shows up when you activate a message and ...
I used the Buddypress Message Compose to send a site wide email to all members wasnt sent tho
wordpress
I'm trying to add some meta fields to a WPSC product using the following code: <code> /** * data callback */ function abc_callback($object, $box) { echo 'callback executed!'; } /** * add custom fields */ function abc_load_post($post_id) { add_meta_box('abc_post_id', 'abc', 'abc_callback', 'post', 'normal', 'default', a...
I can see 2 problems with your code. You seem to want that meta box to appear on product pages, but you actually add it to the post type and not the product post type. The other problem is the hook you attach your function to. Try this: <code> add_action( 'add_meta_boxes_{post_type}', 'abc_load_post' ); </code> Substit...
Why is `add_meta_box` not working?
wordpress
Starting on <code> line 474 </code> of <code> /wp-includes/admin-bar.php </code> there is a function that is declared as the following: <code> function wp_admin_bar_new_content_menu( $wp_admin_bar ) </code> What it does it generates the <code> + New </code> menu item along with any custom post types that a user has <co...
I've not worked with the admin-bar before. However, I found your question interesting and decided to take a look. If you add a function to handle the action hook 'admin_bar_menu' and set the priority to be higher than 70, you will have access to the raw admin_bar_menu nodes where you can modify the properties you are t...
Modify Admin Bar Link
wordpress
Hi I am thinking of changing from the default WordPress commenting system to Disqus or LiveFyre. What are the biggest advantages of such a change, and maybe possible pitfalls I should look out for. Thanks.
When you use Disqus you are in a way giving away the control to that company. The module is indeed very nicely built, you can access Disqus admin section from within your WP admin panel, but like I said; you are handing over the "root control" to Disqus.
Commenting system for WordPress
wordpress
I've been getting a notice when I try to add a new post in two different taxonomies, in one i use a custom meta box and in the other not, however the notice appears for both when trying to add a new item, i see this: Notice: Undefined index: product_noncename in /Applications/MAMP/htdocs/site/wordpress/wp-content/theme...
<code> // Save the Metabox Data function wpt_save_product_meta($post_id, $post) { if($post-&gt;post_type!='post type with metabox') { return $post-&gt;ID; } // verify this came from the our screen and with proper authorization, // because save_post can be triggered at other times if ( !wp_verify_nonce( $_POST['product_...
Metabox nonce PHP notice
wordpress
I'm having issues with this. I have 2 while loops, each getting different custom post types. They both work fine, except, my sidebar content i.e. widgets, is not appearing. I think this is because I am not running the default query. My two queries are: <code> query_posts('post_type=offered'); while (have_posts()) : the...
When you do a query, you change the environment, specifically the current post and query objects. To reset things back to how they were before the query loop you should: <code> query_posts('post_type=offered'); if(have_posts(){ while (have_posts()) : the_post(); ?&gt; ....content endwhile; } wp_reset_query(); // reset ...
Issue with sidebar widgets not showing when I do custom queries
wordpress
Are there any solutions to transform a default image gallery into a simple slideshow as seen in this theme ? Note: click to move to the next picture in the gallery.
Yes, you can use any slider jquery plugin you wish, but to feed the slideshow you need the photos. Galleries in WordPress are composed of posts with post_type attachment, and attachments that are attached to a post have that posts ID as their post_parent. So to get the images for the slideshow or slider, you need to fi...
How to create a simple slideshow out of a post image gallery?
wordpress
How can I insert pictures into a post without any hard coded dimensions (e.g. <code> &lt;img src="" alt="" /&gt; </code> instead of <code> &lt;img src="" alt="" width="" height="" /&gt; </code> )? I don't want my users to switch to the HTML tab and remove the parameters by themselves, so I was wondering if there is any...
I found a solution in the meantime: <code> wp_get_attachment_image_src() </code> to get the <code> src </code> for the images. I think it ends up by being the easiest solution and it requires no filters.
How to insert pictures without hard coded dimensions?
wordpress
i can't understand why so simple feature are disabled by Wordpress Team. I want have line breaking with "br" tag. On one wordpress forum was idea to modificate editor.js (in wp-admin/js) and formating.php (in wp-includes) files. http://wordpress.org/support/topic/ltbrgt-stripping-problem-ultimate-solving I was tryed to...
First things first, modifying core files is extremely frowned upon you will have to make these changes with every upgrade and they can lead to security and other problems. I'm pretty sure there is a plugin that will allow this. I did a simple search and here are a few to try: http://wordpress.org/extend/plugins/preserv...
How to enable the tag in Wordpress posts and pages
wordpress
There is add_action() function inside function which is callback for add_shortcode(). Any idea how to remove this action with the help of custom plugin? Should I hook to any action which is called later then add_shortcode() function? I do not want to removing and re-adding shortcode, because there is huge function beyo...
OK, I found a way. Function add_shortcode is called for the_content filter with priority 11 (after wpautop). So, to remove custom_function() has to be done with the help of this filter (also with priority 11). Solution? <code> add_filter( 'the_content', 'unhook_custom_function', 11 ); function unhook_custom_function( $...
Remove action from shortcode
wordpress
I recently reached 95% full storage on my GMail. Approximately 60% of this was, in fact, email backups from Wordpress' "WP-DB-Backup" plugin on 10+ sites that I manage. (I get a scheduled daily backup of the whole database.) There must be a better way to manage my backups. Ideally, if I can somehow automatically delete...
You can use a plugin like <code> backwpup </code> that lets you: Store backup to Folder Store backup to FTP Server Store backup to Amazon S3 Store backup to Google Storage Store backup to Microsoft Azure (Blob) Store backup to RackSpaceCloud Store backup to DropBox (free) Store backup to SugarSync (free) and manage the...
Managing Backups: Space Issues
wordpress
I'm writing a plugin which uses <code> wp_insert_post() </code> to insert posts programatically and my permalink setting is <code> /%category%/%postname%/ </code> Of all the post inserted, <code> wp_posts.guid </code> shows 2 types of output. Some post will be following <code> /%category%/%postname%/ </code> and some <...
Permalinks in WP do not actually have anything to do with <code> wp_posts.guid </code> any more. I believe that historically they did, and have been left in because of RSS feeds - I.e. changing them would cause peoples feeds to think that the posts had not been read. Your permalink structure is stored within your <code...
wp_insert_post generated mixed permalinks
wordpress
I have a website working with a user registration/login system all working also. I wish to automatically send all users an email that have not used their account for 6 months. I have an idea, but just wondered if there would be a better/more convenient solution. Because this will be done in PHP, I guess this requires a...
Take a look at the Transients API . It's meant to store data temporary. Note, that this doesn't replace a cron job, as it needs "Action" on the site. So if the site isn't requested, where you set/alter/delete a Transient, then nothing happens.
Remind a user about their account if they have not used it for 6 months
wordpress
I am using nextgen gallery plugin with this code: <code> $galleries = $wpdb-&gt;get_results( "SELECT t.*, tt.* FROM $wpdb-&gt;nggallery AS t INNER JOIN $wpdb-&gt;nggpictures AS tt ON t.gid = tt.galleryid WHERE tt.exclude != 1 GROUP BY tt.galleryid ORDER by tt.galleryid"); echo do_shortcode('[nggallery id='.$galleries[0...
After some pain, I found this at the plugin documentation For a single picture : [singlepic id=x w=width h=height mode=web20|watermark float=left|right] So my echo became this: <code> echo '&lt;li&gt; '.do_shortcode('[singlepic id='.$gallery-&gt;previewpic.' w=139 h=83 float=left]').' &lt;a href="#"&gt;'.$gallery-&gt;t...
How could I fix the lowercase problem in nextgen gallery?
wordpress
W3 Total Cache Minification: after adding all my js files in the minification settings, what if something screws up? Is is possible to revert back to the original un-minified files? Thanks.
Just turn off minification. It's not a destructive process, your original files remain untouched.
W3 Total Cache Minification: way to revert back?
wordpress
This is an idea that came through my mind, and I would like to know if possible and how to approach it if so... I have my own wordpress framework that I use as based for all my projects, I manage the content position generated in the content box using shortcodes which respond to an especific div with a location... Said...
The only way I can think of doing this is with JavaScript to regex your parameter and apply a css style to them on the fly. Check out these jquery plugin for ideas: https://github.com/jbr/jQuery.highlightRegex http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html
highlight specific text in the content box
wordpress
I'm working on a plugin to be release to the public, it is a very simple plugin that includes a single html element in the page html. I can do many things to allow users customize its appearance: 1. Let them override a default CSS that is includes as a plugin configuration (on a management screen) 2. Require that they ...
Is it possible? Yes. Option 1 Simply register and enqueue your default stylesheet. The theme stylesheet can then be used to override whatever styles you implemented. <code> function register_my_styles() { wp_register_style( 'default-style', plugins_url('default.css', __FILE__) ); wp_enqueue_style( 'default-style' ); } ...
What is the best way to provide plugin users with a way to customized the styles
wordpress
I recently played with a plugin which I liked a lot, but felt it was missing something. So as first stage I went and wrote a tiny plugin (my first), that just added the needed feature - meaning, that the original plugin still had to be installed for something to work. Now I gave credit to the authors for doing most of ...
I'm assuming for now that the plugin is open source. If so ... Send them an update Most devs appreciate contributions from the community. Contact the original authors and offer your code as a patch to add your new feature. Reference the plugin Optionally, you can just hope that they keep developing the system and offer...
What is the etiquette on extending a plug-in
wordpress
Is there a way to rotate widgets or text blocks with a Flash banner? I had a widget loading a Flash Video loaded by wordTube Flash and YouTube player. The client wanted to rotate this video together with some Flash text (effect showing text being typed). I replaced the Flash text banner by the jQuery Tickertype plugin ...
All details added to question itself. I use a jQuery plugin to load one div and then another. The script added to question is loaded into the theme by added the following code to functions.php: <code> function load_home_rotator() { wp_enqueue_script('rotator', get_stylesheet_directory_uri() . '/js/rotator.js'); } add_a...
Rotate Widgets or Content Blocks every x sec/min
wordpress
i have successfully install and run those projects based on BackPress. SupportPress: https://supportpress.svn.wordpress.org/trunk/ GeoPress: http://geopress.my/ I try to understand how i can build some custom projects that will need the MultiSite feature with the subdomains option. Does anyone knows how to do this? Whi...
BackPress does not offer any multisite support libraries, you'll have to build those yourself with the support of the WordPress multisite source code. The following are the major parts making up multisite functionality: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-admin/network.php , deployment of a multisite e...
BackPress - which libraries i need to load to work with Multisite?
wordpress
I am trying to use pre_get_posts to set posts per page for a single term within a taxonomy. One thing that is throwing me off is setting the term to apply the pre_get_posts to. Here's my code: <code> function filter_press_tax( $query ){ if( $query-&gt;query_vars['tax_query']['taxonomy'] == 'press' &amp;&amp; $query-&gt...
You're almost there mate. Try this though. <code> &lt;?php add_action('pre_get_posts', 'filter_press_tax'); function filter_press_tax( $query ){ if( $query-&gt;is_tax('press') &amp;&amp; $query-&gt;has_term('press')): $query-&gt;set('posts_per_page', 5); return; endif; } ?&gt; </code> You can use any conditional tag or...
Using pre_get_posts to set posts per page, how do I?
wordpress
I am developing a custom theme. I edited my home.php to show something custom. I also edited index.php to display a list of posts or other things. After this I can't get a list of all posts which was by default displayed at the home page. Which URL can I use to access the list of posts?
First, you need to familiarize yourself with the WordPress Template Hierarchy , so that you ensure that you are modifying the appropriate template file: Home : Blog Posts Index page; template file: <code> home.php </code> Front Page : Site Front Page ; template file: <code> front-page.php </code> I am assuming that you...
Showing a list of posts when homepage is custom
wordpress
I would like to add open graph meta tags to my header.php, but can someone explain how this works if header.php comes before my loop with the relevant information?? <code> &lt;meta property="og:title" content="The Rock"/&gt; &lt;meta property="og:type" content="movie"/&gt; &lt;meta property="og:url" content="http://www...
I have this class from a while ago which still works fine on posts and pages using <code> admin_head </code> action hook <code> &lt;?php /** * Simple facebook open graph class for WordPress * * @author Ohad Raz * @version 0.1 * */ class simple_open_graph{ /** * Holds the default image url * @var string * @since 0.1 */ ...
Facebook "like" open graph meta in header.php
wordpress
I used the following to remove certain menus for the "editor" <code> function remove_menus () { global $menu; if( (current_user_can('install_themes')) ) { $restricted = array(); } // check if admin and hide nothing else { // for all other users // Remove Tools, Appearance, Links, Plugins, Comments, if ($current_user-&g...
A much simpler solution is to use <code> remove_menu_page </code> , <code> remove_submenu_page </code> and <code> remove_menu </code> (admin bar). Your example of removing the sub-menu item for "add new" would be <code> remove_submenu_page( 'edit.php?post_type=page', 'post-new.php?post_type=page' ); </code> To remove i...
Removing specific menu items?
wordpress
I've created a function that automatically creates a new post for people when they register. It works great on a standard site but in multisite it stops working. I've spent hours trying to debug it. Is there a better hook to use than <code> user_register </code> in multisite?
There is the action hook <code> wpmu_new_user </code> . <code> /* * Create a user. * * This function runs when a user self-registers as well as when * a Super Admin creates a new user. Hook to 'wpmu_new_user' for events * that should affect all new users, but only on Multisite (otherwise * use 'user_register'). </code>
Does the user_register change in multisite?
wordpress
I'm using the Settings API to allow the user to toggle the <code> has_archive </code> option on some custom post types. When the user turns archives on or off, I want to flush the rewrite rules. If I had written the saving function myself, I could just call <code> flush_rewrite_rules() </code> and be done with it, but ...
You simply need to visit the Settings > Permalink page (you don't have to do anything there) after saving the settings. If I had written the saving function myself, I could just call flush_rewrite_rules() Not quite. <code> flush_rewrite_rules() </code> would have to be called after the custom post type is 'updated' to ...
How do I flush the rules after saving settings using the Settings API?
wordpress
What's the quickest and easiest way to select every second element in the loop? At the moment I'm using this strange method: <code> &lt;ul&gt; &lt;?php $k = 1; ?&gt; &lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt; &lt;li class="&lt;?php if($k%2 == 0) echo 'last'; ?&gt;"&gt;&lt;?php the_content(); ...
I wouldn't consider that strange :). WordPress uses a similar method to apply the 'alternate' class to every other row in the tables on the admin page, something like: <code> &lt;ul&gt; &lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt; &lt;?php $class = (empty($class) ? 'class="alternate"' : '');?&g...
Cleanest Way to Select Every Second Element in a Loop?
wordpress