Tag Info

Hot answers tagged


Lets start by removing the query_posts() from your code since you already have it's better brother new WP_Query. Then what you will need is to use the category_name param on your WP_Query. You should always search on the WP_Query page before you ask here, you can find more referencers there. Here is how @speedypancake resolved the issue: <?php ...


Take a look the section called Preserving Existing Query Parameters on http://codex.wordpress.org/Function_Reference/query_posts Try merging in the existing query parameters; they might be getting overridden. Instead of: <?php query_posts('cat=4'); ?> try global $query_string; query_posts( $query_string . '&cat=4' );


You might be running up against WordPress's global $blog_id variable in test case #2. Try this: foreach($sites as $my_blog_id => $name) { switch_to_blog($my_blog_id); $sites[$my_blog_id] = get_bloginfo('name'); restore_current_blog(); }


This can be done with a very short plugin. function posts_on_home_page( $posts_per_page ) { if ( is_home() ) return 5; return $posts_per_page; } add_filter( 'pre_option_posts_per_page', 'posts_on_home_page' ); This is actually pretty close to the Codex example for pre_option_(option_name).


When the instance of WP_Query is not a variable on the PHP file you are working on it tends to be the "main" query and to edit this instance of the WP_Query you will need to Hook to the pre_get_posts action and change what you need there. Here is an Exemple: <?php add_action( 'pre_get_posts', 'q166401_pre_get_posts', 10, 1 ); /** * On this case I will ...

Only top voted, non community-wiki answers of a minimum length are eligible