Multiple keyword search
Multiple keyword search
Multiple keyword search
You’re on the right track. You can do this with just one MySQL query instead of two by joining on the post_parent. Drop this function into your functions.php file, then in your template you can replace your WP_Query call with $results = wpse_84810_get_grandchildren();, change your if clause to be if( $results && $results->have_posts() ), then … Read more
I found a solution that allows me to search posts by tags and categories while still searching title and content. This does exactly what I was looking for. Credit: https://rfmeier.net/include-category-and-post-tag-names-in-the-wordpress-search/ add_filter( ‘posts_join’, ‘search_join’, 10, 2 ); /** * Joins the terms, term_relationship, and term_taxonomy tables. * * @global $wpdb * * @param string $join The … Read more
Do you have a https version of your website ? I ask this because I recently came across a project which was a website which could be reached both in http and https. Thus I had to specify it to the ajax_url function. So, in your case, I suggest you try: $protocol = isset( $_SERVER[‘HTTPS’] … Read more
I depends if you’re looking for an empty value: $args = array( ‘post_type’ => LANDING__CUSTOM_POST, ‘meta_query’ => array( array( ‘key’ => ‘landing_exported’, ‘value’ => ”, ‘compare’ => ‘=’ ) ) ); // query $the_query = new WP_Query( $args ); which searches for value like: meta_value=”” or if you are looking for actually a NULL value … Read more
After hours of googling I came up with following solution. Maybe once will help to someone. 1) query post where is used gutenberg youtube block: $args = array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘s’ => ‘core-embed/youtube’, ‘posts_per_page’ => 1 ); $query = new WP_Query($args); 2) extract the URL from youtube block of the post … Read more
WordPress queries are indeed represented by WP_Query objects. The snippet example you have is secondary query, as opposed to main query – which is run by WP itself during core load and stored in global $wp_query variable. Typically it is better (for performance and compatibility) to modify main query for set of posts that is … Read more
By default– that is, unlss told otherwise– WP_Query will search the post post type. You may supply ‘post_type’ => ‘any’ to retrieve all post types, but be aware that things like attachments are post types. For example… $args = array( ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ‘ignore_sticky_posts’ => true, ‘post_type’ => ‘any’ ); $qry = … Read more
You would need two queries to achieve this. You can’t specify the limit per post type in WP_Query (without modifying the raw SQL). What you could do is simply query the posts and the photos and merge the resulting arrays: // Fetch posts $posts_query = new WP_Query( array( ‘post_type’=> ‘post’, ‘orderby’ => ‘date’, ‘posts_per_page’ => … Read more
Your meta fields are JOINing as mt* aliases in that query. Look for the lines like: INNER JOIN wp_postmeta AS mt1 ON … But the ORDER BY parameter is just wp_postmeta.meta_value, which doesn’t actually make all that much sense. If that isn’t a bug, I call it bad design or very limited design, but moving … Read more