ok, maybe I need another approach. I can make a separate category for stickies (so I dont’t use the sticky option in the wp-admin). Then I could make a different loop for both categories.
I thought it should work like this:
$stickies = new WP_Query(‘category_name=Stickies’);
… Loop trough $stickies->have_posts()
$news = new WP_Query(‘category_name=Uncategorized’);
… Loop trough $news->have_posts()
I’m using valid category names. Still $news and $stickies return 0 posts. Is ‘category_name’ not a valid parameter?
Or has someone another suggestion to solve my problem?
I haven’t done any serious work with WordPress in ages, but if you try to use an if statement, or a switch statement instead of two loops, you may find that your problem disappears. But again, I haven’t looked into it.
You mean something like this?
if( post=sticky) : show the post ?
I’dont think that will fix it.
Let’s say I use the standard post-array, there will be no sticky posts in de array on page 2, 3, 4… ect. So the if-stament will just result in not displaying any sticky posts.
Ok. I found a Solution, but it is not very clean.
My sticky posts are marked as Sticky in the WP-admin, AND they need to be in a category different from the newsitems.
I select my sticky posts
$stickies = new WP_Query();
$stickies->query(array('post__in'=>get_option('sticky_posts')));
the loop statement is like this:
while($stickies->have_posts()):$stickies->the_post()
The newsposts are selected this way
query_posts('category_name=Uncategorized&paged=' . $paged .'');
// the loop
while(have_posts()): the_post();