WP Query – Show custom posts only if user contain some user meta

You could approach in two steps. First get all the users that match your criteria $user_ids = get_users([ ‘meta_key’ => ‘activeacc’, ‘meta_value’ => true, // or whatever value you are storing ‘fields’ => ‘ID’, ]); and then run your WP_Query for only those users $properties = new WP_Query([ ‘post_type’ => ‘property’, ‘author__in’ => $user_ids, ]); … Read more

Display ACF object field data using Elementor Custom Query

The issue can be solved with this code : function my_cpt_query( $query ) { $myPostObjetField= get_field(‘cpt1_field_for_cpt2’,$post_id,false); foreach( $myPostObjetField as $post_field_item_value ) { $ids[] = (int) $post_field_item_value; } $query->set( ‘post_type’, ‘CPT2’); $query->set( ‘post__in’, $ids); } add_action( ‘elementor/query/13600’, ‘my_cpt_query’ );

Count words for all posts by all authors

You will need a function to get all the published posts and count the words. function wpse410818_count_published_words() { $posts = new WP_Query(array( ‘post_type’ => array( ‘post’ ), ‘post_status’ => ‘publish’, )); $count = 0; //Starting words count if ( $posts->have_posts() ) { while ( $posts->have_posts() ) { $posts->the_post(); //Add to the word count $count += … Read more