How to do logical OR in terms in WP Query?

As WP_Query doesn’t natively allow you to do logical OR operations (except on meta values), one option is just to run two queries to get all the Post ID’s, then pass those to a new WP_Query which you can use for a loop. This is quite long and requires 3 queries, so perhaps someone will … Read more

get_post() is not returning correct value

That’s not how you update posts. Because you used raw SQL to do it, none of the filters or actions fired, and none of WP_Cache was updated, so it’ll return an old version of the post it fetched earlier when you call get_post. Instead, if you want to update a post, use wp_insert_post and pass … Read more

How to show meta value code HTML after x paragraph

The purpose of echo is sending strings to the output buffer. In your code you are concatenating the result of 4 to the result of the call to echo, which returns nothing. Also, get_post_meta already returns a string so you don’t have to do the type cast. Try: add_filter( ‘the_content’, ‘prefix_insert_post’ ); function prefix_insert_post( $content … Read more

Why tax_query in WP_Query not working

Try to change $cat_name by the category ID. $term_name = get_query_var(‘taxonomy’); // current taxonomy $cate = get_queried_object(); $cat_id = $cate->term_id; // current category ID echo $term_name; echo $cat_id; $wp_query = new WP_Query(array(‘post_type’=>’st_ai’, ‘post_status’ => ‘publish’, ‘tax_query’ => array( array( ‘taxonomy’ => $term_name, ‘field’ => ‘slug’, ‘term’ => $cat_id, ) ) )); if ( $wp_query->have_posts() ) … Read more

Create a page template for “top rated posts” but show full content and not just a list

I opened up that plugin (WP-PostRatings) and located the get_most_rated() function. It’s in the following file: includes/postratings-stats.php In that file, on line 57 you get the following: foreach ($most_rated as $post) { $output .= expand_ratings_template($temp, $post, null, $chars, false).”\n”; } From that, I went searching for the expand_ratings_template() function. Found that in the following file: … Read more

WP_Query Results Issue with ACF

It seems that the format I used for $argsar needs to be changed to $argsar = array ( ‘post_type’ => ‘auctionroom’, ‘meta_query’ => array( array( ‘key’ => ‘auctionroom_username’, ‘compare’ => ‘=’, ‘value’ => $auctionroomname ) ) ); Hope it helps someone