query_posts with sorting on a custom datestamp
query_posts with sorting on a custom datestamp
query_posts with sorting on a custom datestamp
First of all, don’t use query_posts Form Codex: Note: This function isn’t meant to be used by plugins or themes. As explained later, there are better, more performant options to alter the main query. query_posts() is overly simplistic and problematic way to modify main query of a page by replacing it with new instance of … Read more
query_posts() is overly simplistic and a problematic way to modify the main query of a page by replacing it with new instance of the query. It is inefficient (re-runs SQL queries) and will outright fail in some circumstances (especially often when dealing with posts pagination). Any modern WP code should use more reliable methods, like … Read more
Query Distinct Taxonomies of Custom Post Type
query_post causes the posts to be loaded twice on load more posts
It’s a little hard to untangle this, but I’ll try to address your points one by one. create a separate 404.php page to control the output of that page. (and the silence about any attempt to do it otherwise) 404.php template controls presentation of 404 page. This is highly in line with rest of WP … Read more
This is untested, but I think it should work. Add the filter in pre_get_posts if it’s your post type archive, otherwise remove it for any queries that follow the post type archive main query. function wpd_add_posts_orderby( $query ){ if( $query->is_post_type_archive(‘your-cpt’) ){ add_filter(‘posts_orderby’, ‘edit_posts_orderby’); } else { remove_filter(‘posts_orderby’, ‘edit_posts_orderby’); } } add_action( ‘pre_get_posts’, ‘wpd_add_posts_orderby’ );
If you take a look at the category parameters of WP_Query, you’ll see that you can use either cat=-12 or category__not_in’ => 12 to exclude a category with ID 12 in your custom query. I just also want to point out a few things here. showposts is depreciated, you should be using posts_per_page. Also ‘showposts=6’ … Read more
“The Loop” is already a loop, so I don’t see the need for your second loop. In fact, the secondary while loop shouldn’t work because you keep resetting it to 1 for every post. You also have some PHP syntax issues like $echo (that’s a variable) instead of echo and the way you concatenate the … Read more
How to organize a WP_Query’s list of posts by category and display category title?