How to prevent queried posts from being added to cache?

The posts array result in WP_Query is mapped to get_post() (here and here) with: $this->posts = array_map( ‘get_post’, $this->posts ); and that seems to be adding posts to the object cache even though the cache_results argument is set to false in WP_Query. Within the get_post() function (here) we have: $_post = WP_Post::get_instance( $post ); for … Read more

How to use order RAND() on WordPress?

You are right that you can’t have WordPress order the retrieved posts randomly. So you’ll have to do that yourself after you have retrieved the array of post objects. Let’s call that $my_posts. Because you don’t know how many of the posts in that array are featured, you will have to loop through them to … Read more

Query posts with more than 20 comments

WP_Query does not currently support querying by the comment_count field, but there is a proposed patch for this functionality. See Trac ticket #28399. Update: #28399 has been fixed and should land in version 4.9 In the meantime, here is a workaround based on information from this post which will alter the where clause of a … Read more

Getting all custom posts with a certain category

$blabla = new Query($args); should be $blabla = new WP_Query($args); UPDATE Your actual code should be something like: $args = array( ‘post_type’ => ‘fb’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘fbcate_category’, ‘field’ => ‘id’, ‘terms’ => ’35’, ), ), ‘order’ => ‘DESC’, ‘posts_per_page’ => -1, ); $posts_array = new WP_Query($args); Where taxonomy is your taxonomy … Read more

Remove ellipsis from the excerpt retrieved using get_the_excerpt()

The third field in add_filter() is priority. Default WP hook priority is 10. You can omit the 1 altogether, or still declare number of arguments accepting by function by passing it as 4th field. add_filter(‘excerpt_more’, ‘change_excerpt_more’, 10, 1); OR for default: add_filter(‘excerpt_more’, ‘change_excerpt_more’); re: questions in comments still wondering why it wouldn’t work without having … Read more