Question

In a category.php template, I built a function that lists "featured" posts before the main loop. The featured posts are selected using a custom field and get_posts():

function list_featured_articles(){
 $featured_posts = get_posts('meta_key=featured_article&meta_value=on&numberposts=10&order=DESC&orderby=post_date');
}

My category.php template:

echo list_featured_articles();
get_template_part( 'loop', 'category' );

It works fine, except that the featured articles are listed also in the category list of articles. I would like, from my function, get the featured posts' ID and remove them from the main loop. Is there a proper way to do it? I figure i could use a GLOBAL variable storing an array of excluded ids, but i'd like to avoid using Globals for that.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top