Query Posts Creates 404 Error
You are not modifying your query, but nuking it completely. Please see query_posts() documentation in Codex on how to correctly re-run query with changed arguments.
You are not modifying your query, but nuking it completely. Please see query_posts() documentation in Codex on how to correctly re-run query with changed arguments.
Have you tried using meta_query? More details at http://codex.wordpress.org/Class_Reference/WP_Query.
I’m pretty sure you can use get_pages (http://codex.wordpress.org/Function_Reference/get_pages) function to solve this. It has child_of parameter which does exactly what you wanted. The only problem is that it returns posts and not set $wp_query, so you can’t use it as loop, but you can always call setup_postdata and then use template tags as in normal … Read more
Can this help you? — http://wordpress.org/support/topic/query-post-to-show-one-post-per-author ps. I should add this as a comment, but I can’t, sorry.
When using cat in the query you need to specify the category id not name. Try this. <?php $gallery = get_cat_id(‘gallery’); $shirts = get_cat_id(‘shirts’); $hoodies = get_cat_id(‘hoodies’); $excluded_cats=”-“.$gallery.’,-‘.$shirts.’,-‘.$hoodies; $limit = 5; $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; query_posts( ‘cat=”.$excluded_cats.”&showposts=” . $limit . “&paged=’ . $paged ); ?>
See the offset argument: …&offset=5… And avoid using global variables, and query_posts. Use the pre_get_posts action instead.
Never tested this ,but i believe you need to add WHERE clause to your query with time difference like so : $timediff .= ” AND post_date > ‘” . date(‘Y-m-d’, strtotime(‘-2 days’)) . “‘”; you can find it also in the codex http://codex.wordpress.org/Class_Reference/WP_Query#Time_Parameters If you do not want to use on query, but inside the … Read more
How about something like this where you filter the posts once the WP_Query gets them?
Sorry! Turns out the problem with query_posts failing here was due to my PHP memory_limit. I changed it from 8mb to 128mb and the problem goes away.
here’s what I ended up doing: <?php query_posts(array( ‘category__not_in’ => array($headline), ‘post__not_in’ => $postnotin, ‘paged’ => $paged, ‘posts_per_page’ => 5 )); if ( have_posts() ): $postCount = 0; ?> <?php while ( have_posts() ) : the_post(); $postCount++; if ($postCount < 6) { ?> [all my code] <?php } #end if ?> <?php endwhile;?>