Advanced Search – Is this possible?
Advanced Search – Is this possible?
Advanced Search – Is this possible?
Add adjacent post function inside custom recent post function
<?php // query only child pages of custom post type $customQuery = array( ‘post_type’ => ‘CUSTOM_POST_TYPE’, ‘posts_per_page’ => ’10’, ‘post_parent__not_in’ => array(0), ); $custom = new WP_Query( $customQuery ); if ($custom->have_posts()) : while ( $custom->have_posts()) : $custom->the_post(); ?> DO STUFF <?php endwhile; endif; wp_reset_query(); ?>
It’s because you’re not outputting the ID into data-like: data-like=”<?php echo isset($existQuery->posts[0]->ID); ?>” You are outputting whether the ID isset(), which is true, which is being turned into 1. You need to output the actual ID: data-like=”<?php echo isset( $existQuery->posts[0]->ID ) ? esc_attr( $existQuery->posts[0]->ID ) : ”; ?>”
You could try modifying the tax query to use the relation parameter and add a second clause that matches any post that does not have the matched string value in the meta array. See Taxonomy Parameters. EDIT: Thank you for pointing that out, Tom. You’re correct, I’ve updated to reflect. function group_matched_posts_at_top( $query ) { … Read more
Found the solution in case anyone is having the same problem. Before the Query call I ran: remove_all_actions(‘pre_get_posts’);
You added title inside $args[‘meta_query’] and that’s why your query doesn’t work. Checking the documentation (get_posts / WP_Query) you will find the available parameters, among them title and s. $args = array( ‘s’ => ‘apple’, ‘post_type’ => ‘product’ // // other parameters // ‘status`, ‘orderby’, ‘meta_query’, … ) $posts = get_posts($args); If you use the … Read more
Neither will be faster because the root of the performance problem is the WP table design, not the plugin. The post meta table is optimised for finding values when you already know the post ID/keys, it’s not designed for searches, though there are mitigations. Searches/grouping/finding is what the taxonomy tables were created for. Finding all … Read more
Custom Taxonomy in custom REST API search
Your query syntax looked good, although you could instead add a direct meta/taxonomy query clause array such as $meta_query[] = array( ‘key’ => ‘_price’, … ) instead of $meta_query[] = array( ‘relation’ => ‘AND’, array( ‘key’ => ‘_price’, … ) ). However, I spotted 2 main issues with your code: Issue 1: Your custom pagination … Read more