Tag Info

Hot answers tagged

2

Try using 'NOT EXISTS' instead of 'NOT LIKE' and remove the value ( it'll be removed by WP with NOT EXISTS ): $args = array( 'post_type' => 'post', 'posts_per_page' => 5, 'meta_query' => array( array( 'key' => 'verified', 'compare' => 'NOT EXISTS' ) ) ); $query = new WP_Query( $args ...


2

I think that your problem is a syntax error: name='s should be name='s'.


1

I wrote an article on this a while back: Excluding Certain Posts Or Pages From Search Results In WordPress But the long and short of it is: function mySearchFilter($query) { if ($query->is_search) { $query->set('post_type', 'post'); }; return $query; }; add_filter('pre_get_posts','mySearchFilter'); You can add that to your ...


1

Although this is possible, it really is not viable. I've done a lot of research on this subject, but could not find a straight forward answer I went and had a look at the WP_Query class for a possible solution, and I came to the conclusion that what I was trying to accomplish would not be possible with a simple one or two liner code. PITFALLS To get the ...


1

You can set tax query in pre_get_posts hook as well: $query->set('tax_query', array(__standart parameters__));


1

WordPress submits search, by default to bloginfo( 'wpurl' ) with search parameter of s set to the search term.. You should be able to do this yourself. You will need to use GET on the form and set name="s" in your search field. That said, I agree with the comment above by @Howdy_McGee that you should be using get_search_form(). You should just apply ...


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 ...



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