Tag Info

Hot answers tagged

5

Your problem is that you are not resetting all the needed query variables, like WP_Query::$is_page, WP_Query::$is_single and WP_Query::$is_archive. Also note that 'pre_get_posts' is fired for all queries, the main and the secondaries, so you should check that you are working on the main query. Finally, when you get data from $_GETyou should sanitize it ...


2

The solution: $query = array( 'post_status' => 'publish', 'post_type' => 'product', 'posts_per_page' => 10, 'meta_query' => array( 'key' => '_price', 'value' => array(50, 100), 'compare' => 'BETWEEN', 'type' => 'NUMERIC' ), ); $wpquery = WP_Query($query); // return 10 products ...


1

The problem in this case is the name of the post type, action. WordPress core uses the query var action for its own purposes, so this has created a conflict somewhere within the code. The solution is to rename the post type to something unique to remove the conflict.


1

You could add a second array to check if the 'DTEND' value is not set: $args = array_merge( $wp_query->query_vars, array( 'meta_query'=> array( 'relation' => 'OR', array( 'key' => 'DTEND', 'compare' => '>=', ...


1

It depends on what the template uses to output whatever you're trying to remove. If you look in source at whatever function is outputting what you want to remove, they each have a filter to let you modify output where you can __return_false instead, however, if there's text or markup surrounding those template tags, your only option is to modify the ...


1

This would only work if the keyword exactly matches the tag that you are searching for, and unfortunately, tag data isn't indexed by WordPress search by default, so that won't yield anything either. If you want to index the tags and include that in search results you might want to use a plugin. Relevanassi might do the trick, but if you don't mind spending a ...


1

Your problem is more than likely that you are nullifying your search results. $keyword = get_search_query(); Above, you are grabbing the search variable provided $args = array( 'post_type' => array('case_studies', 'news', 'events'), 'post_status' => 'publish', 's' => $keyword, 'tag' => $keyword, ); Here, you are executing a ...


1

This is quite an unusual case an and also one that can fail on you and give quite unexpexted results By default, this is not just possible at all. I really tried to overthink this, and I cannot come up with a solution that will work by simply using one query, except maybe by using a custom SQL query or the filters supplied in WP_Query. Unfortunately my SQL ...


1

Although @MayeenulIslam's answer could work, I think the correct way to do an advanced search is using the pre_get_posts action hook. Step 1: search form This step equal to step 1 in the other answer, just changed the id of the "name" filed used for search to "s", so it will be used directly for as search field. Save this code in searchform-advanced.php ...



Only top voted, non community-wiki answers of a minimum length are eligible