Timeline for how to exclude "featured" posts from the main loop?
Current License: CC BY-SA 3.0
9 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Oct 29, 2011 at 21:56 | history | edited | Chip Bennett | CC BY-SA 3.0 |
added 490 characters in body
|
Oct 29, 2011 at 21:55 | vote | accept | pixeline | ||
Oct 29, 2011 at 21:55 | comment | added | pixeline | Yeah, i posted my comments pretty much at the same time as you :) Thanks for making that point crystal clear! Your answer sent me on the right track so i'll select it. thanks! | |
Oct 29, 2011 at 21:53 | comment | added | Chip Bennett |
"although i'm still interested to know if your answer replaces the query or creates an additional one"... from my above comment: The query_posts() function is used to alter the primary Loop. It alters the primary Loop; it does not create a new loop.
|
|
Oct 29, 2011 at 21:51 | comment | added | pixeline |
ok i got it: i adapted your proposal: In my function i stored the IDs in a global variable. I then use it in my category.php template like this, before calling the loop: $exclude_featured_args = array( 'post__not_in' => $excluded_posts ); $merged_args = array_merge( $wp_query->query, $exclude_featured_args ); query_posts( $merged_args );
|
|
Oct 29, 2011 at 21:47 | comment | added | pixeline | Forgive me for not mentioning it directly: my function is set up so that if there are no "featured" post, it automatically takes the most recent ones and display them as "featured". So i can't really take that road (although i'm still interested to know if your answer replaces the query or creates an additional one). | |
Oct 29, 2011 at 21:44 | comment | added | Chip Bennett |
You should read the Codex link for query_posts() , as it answers this question. The query_posts() function is used to alter the primary Loop.
|
|
Oct 29, 2011 at 21:43 | comment | added | pixeline | this sounds good, but would this makes an additional sql query or would it replace the initial "main" query? | |
Oct 29, 2011 at 21:33 | history | answered | Chip Bennett | CC BY-SA 3.0 |