Searching in categories AND custom fields

Adding the tax_query parameter to the $args array with the proper arguments will check for the category as well (untested): $args = array( ‘post_type’ => ‘product’, ‘posts_per_page’ => 15, ‘paged’ => $paged, ‘meta_query’ => array( array( ‘key’ => ‘meta_easyfatt_libero_1’, ‘value’ => ‘Men’, ‘compare’ => ‘LIKE’, ), ), ‘tax_query’ => array( array( ‘taxonomy’ => ‘product_cat’, ‘field’ … Read more

Apply Style variation to specific pages

According to the documentation on Style Variations, it would not appear so. The intent of Style Variations is to be “skins” for your theme and site, rather than for individual pages. However, CSS can be used to apply different styles to specific pages: the <body> tag of each page has classes that can be used … Read more

WP backend, Show only own comments (give to users who wrote/published/assigned) posts

Using the comments_pre_query filter, this seemed to work well in development and testing: /** * @param null $comment_data Return an array of comment data to short-circuit WP’s comment query. * @param WP_Comment_Query $query WP_Comment_Query instance, passed by reference. */ add_filter( ‘comments_pre_query’, static function ( $comment_data, $query ) { // Limit to admin area. if ( … Read more

$_GET[”] variable with nonce verification

There are two ways of creating nonce verification for $_GET parameters: If you are coming from a form, you can use the wp_nonce_field function to create your own field. For example: <form action=”edit.php” method=”get”> <input type=”text” name=”example”> ….. <?php wp_nonce_field(‘my_custom_action’, ‘my_custom_name’); ?> <input type=”submit” value=”Submit”> </form> If you are coming from a link you created, … Read more

Getting featured image from WP_Query

Suggest to reformat the data like such (untested): function load_more_blogs() { … $results = array(); foreach ( $query->posts as $post ) { $results[] = array( ‘post’ => $post, ‘image’ => get_the_post_thumbnail( $post->ID, ‘post-thumbnail’ ), ); } wp_send_json_success( $results ); exit(); } This will give you an array of arrays, with the inner array have two … Read more

How do I group results from wp-query

Need to track the previous job title, and if it’s different, insert your line break. Untested: $prev_job_title = null; while ( $staff->have_posts() ) { $staff->the_post(); $job_title = get_post_meta( get_the_ID(), ‘job_title’, true ); if ( $prev_job_title !== $job_title ) { printf( ‘<h2>%s</h2>’, esc_html( $job_title ) ); $prev_job_title = $job_title; } // Staff markup. }