It's my 1st post because I prefeer to solve my problems alone, but this whole WP is realy p***ng me off :/
For me WP is so limited (sorry), everything have to be made in wicked, long, "go arround" way ... but it's no time to complain.
I have to use WP for something (custom theme) so I want to use WP_Query to get some posts before the main loop fire.
Made something like this:
<?php $sticky = get_option( 'sticky_posts' ); $args=array( 'post__in' => $sticky, 'caller_get_posts'=>1, 'orderby' => 'ID', 'posts_per_page' => 3 ); $my_query = new WP_Query($args); while ($my_query->have_posts()) : $my_query->the_post(); ?> <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a><?php the_category_id(); ?></h2> <?php endwhile; ?>
As You can see I take 3 newest sticky posts (caller_get_posts to prevent showing all sticky posts or other wierd things).
I made the_category_id() to be sure in which category returned posts are (this whole header in loop is for testing now).
Everything goes OK, loop is working, main loop is not affected and is going its own way.
I have a problem when I try to add one more var to query:
$args=array( 'post__in' => $sticky, 'cat' => 15, 'caller_get_posts'=>1, 'orderby' => 'ID', 'posts_per_page' => 3 );
When I add 'cat' I get NO RESULTS. ZERO, none, nada ...
"Funniest" (not for me - I hate if something is working against the logic) thing is that I used cat IDs of returned posts (the_category_id()) from this 1st loop (those are IDs of subcategories). I've tried top level cat id too - nothing.
Even if I make:
$args=array( 'cat' => 6 ); //i'm sure that this cat (6) exists and there are 60 posts in it!
Is WP realy so ... ehh ... not worth those words ...
I just want to have 3 custom queries - each to take 3 sticky posts from specified categories + normal main loop with posts__not_in $sticky to prevent duplicates (which works too without 'cat'). Each post is only in ONE subcategory (and not added to main cat because I want to have links like /cat/subcat/postname/ - if I add it to cat and subcat then the link will be made from lowest ID and that means - /cat/postname/)
Wordpres is realy pain in the a*s if You prefeer frameworks, pure php etc. but it have to be WP this time :(
PS. Using WP 2.9.2 - wasn't able to pick this version from the list when I was creating this post.