How to filter my search in post if contains a word in title, content or excerpt?

Well, for whoever went under the same question, I found the solution: I’ve changed the filter and looks like this now: add_filter( ‘posts_where’, ‘general_filter’, 10, 2 ); $posts = new WP_Query($args); remove_filter( ‘posts_where’, ‘general_filter’, 10, 2 ); and the function… function general_filter( $where, &$wp_query ) { global $wpdb; if ( $search_term = $wp_query->get( ‘search_prod_title’ ) … Read more

Get users that likes the post

It appears that you are storing the data in the post’s meta, not user’s meta. Therefore, you need to retrieve it by directly getting the meta for that post, not by doing a user query. Let’s say your post’s ID is $post_id: First, retrieve the meta by get_post_meta(): $users = get_post_meta ( $post_id, ‘post_liked_users’, false … Read more

WP_Query – Exclude Posts

You’ll need a second tax query for posts not in the child categories of the given category. To do that you’ll need to get the IDs of the children. This is possible with get_term_children(): $args = [ ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => $post_number + 1, ‘paged’ => ( get_query_var( ‘paged’ ) ) … Read more

1/3 of posts different class

The explanation is in the comments: <?php … if ( $query->have_posts() ) : //number of small ones needed = a third of total number of posts $numsmallneeded = round($query->post_count / 3); … while ( $query->have_posts() ) : $query->the_post(); //if no more small sizes are needed, use big if ( !$numsmallneeded ) $size = 1; //if … Read more

Tax query AND/OR meta query [duplicate]

It’s not possible without a more custom query/filter. I have achieved it with a filter (code taken from this guy on this gist – https://gist.github.com/elvismdev/61f8509eff8abcc21ef84154b74fbf56) function f1_egpaf_meta_or_tax( $where, \WP_Query $q ) { // Get query vars. $tax_args = isset( $q->query_vars[‘tax_query’] ) ? $q->query_vars[‘tax_query’] : null; $meta_args = isset( $q->query_vars[‘meta_query’] ) ? $q->query_vars[‘meta_query’] : null; $meta_or_tax … Read more