Tag Info

New answers tagged

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


0

Got a working version, the input and button must have name="s" and id="searchsubmit" respectfully and the form method="get" $url = home_url('/'); <form role="search" method="get" action="' . $url . '"> <input name="s" type="search"> <button id="searchsubmit" type="submit">Search</button> </form> My roots theme didn't ...


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


0

I created a tiny plugin for this :) and fixed the issue. https://wordpress.org/plugins/wp-search-ignore-html-tags/ Just one or 2 lines of code. Worked in most cases.


0

Normally, copying index.php file for the theme as search.php will let you have a new base template to work off of with the same styles and look as your theme, assuming the theme implemented index.php decently. That would give you a solid start to be able to make changes to provided nothing is using a hook such as template_redirect to hijack the search ...


0

The reason for this is that WordPress searches for matches using LIKE %post%, meaning that any post (that is Post, Page or custom post type object) that contains post in it's title or content is found. You can alter this default behaviour by using the posts_where action hook. add_action( 'posts_where', 'my_alter_search_where' ); function ...


1

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


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


0

I noticed that your goal is to have an editable content on the search result. You can use another method to do that, by calling the content of the page from your search.php file. You can start by creating a page with the slug search-page as usual. You can also add post meta / custom fields as you need. And now you can start editing the search.php. Inside ...


0

The quick and simple method might be to create a custom page template and have the search form send the user to the page that you create with it. <?php /* Template Name: Location Results */ if ( isset($_REQUEST['search_field_name']) && !empty($_REQUEST['search_field_name']) ) { # Read and escape the input data # Do your query, grab your ...


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


2

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


0

Thanks to WordPress 4.1 you can do better for meta_query : https://make.wordpress.org/core/2014/10/20/update-on-query-improvements-in-4-1/ function recherche_avancee( $query ) { if ( !is_admin() && $query->is_search ) { $meta_query = array( 'relation' => 'OR' array( 'relation' => 'OR', ...


0

A simple way to do is to edit your theme's "search.php" (copying it from the parent theme into your child theme's directory first if you're using a child theme) and then before the posts loop putting something like: <?php if ( $tag = get_term_by( 'name', get_search_query(), 'post_tag' ) ) { ?> ...


0

First, do not query_posts; use WP Query instead. That being said, I assume that pce_monday_open is lower than pce_monday_close and that you want posts between pce_monday_open and pce_monday_close, so I think your comparison logic is wrong. Also, you may need to set the relationship between the two meta query arrays: $pce_arg = array( 'cat' => 6, ...


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



Top 50 recent answers are included