Forums › Forums › Search & Filter Pro › Search Results Title in Genesis Child Theme
Tagged: Genesis, search result title
- This topic has 4 replies, 2 voices, and was last updated 7 years, 4 months ago by Anonymous.
-
Anonymous(Private) August 5, 2017 at 11:00 pm #124673
My problem sounds close to these two. But I can’t find anything that works.
How to set a title for every search
https://support.searchandfilter.com/forums/topic/how-to-set-a-title-for-every-search/Update search results page title
https://support.searchandfilter.com/forums/topic/update-search-results-page-title/I am trying to get a Search Results title instead of just having ‘Search Results for:’ with nothing following it. I am reading up on different themes — I am running Genesis and Yoast. I added the WP code that I believe is supposed to affect this, but it did not work.
So, when I select an item (‘Attention’) from a custom taxonomy (a dropdown with 15 items). I get the correct results, but no search title.
The search title should read, ‘Search Results for: Attention.’
But instead it reads, ‘Search Results for:’
I’m showing results as ‘an archive,’ I use a custom template ‘search.php’ (which is not custom, it’s just the Genesis default). I know that when I try to use a custom slug, everything breaks. This looks like a separate issue.
Ajax is not turned on
MODERATOR — “The Title on the search page is a theme issue and you may have to hand code it in the template file you use. Some themes make it very hard to add in any other way.”
Okay, I created a copy of ‘search.php’ and called it ‘search-filter.php’ here is the code. I am not sure how to modify it.
———————————-function genesis_do_search_title() { $title = sprintf( '<div class="archive-description"><h1 class="archive-title">%s %s</h1></div>', apply_filters( 'genesis_search_title_text', __( 'Search Results for:', 'genesis' ) ), get_search_query() ); echo apply_filters( 'genesis_search_title_output', $title ) . "\n"; } genesis();
Trevor(Private) August 6, 2017 at 8:42 am #124680I edited your post to put that code in a code block.
I think this would be the new code:
function genesis_do_search_title() { $title = sprintf( '<div class="archive-description"><h1 class="archive-title">%s %s</h1></div>', apply_filters( 'genesis_search_title_text', __( 'Search Results', 'genesis' ) ), get_search_query() ); echo apply_filters( 'genesis_search_title_output', $title ) . "\n"; } genesis();
Anonymous(Private) August 6, 2017 at 11:00 pm #124738Thank you so much for getting back to me so fast! The new code removes the “for:” but does not provide a label for what I am searching for. So it is the same problem.
This only occurs on the custom taxonomies of which there are four. I also have a Type Any Term field box via Search and Filter Pro as an option. When I type a term there, such as “Wallingford”, a full search title is returned in Search results: “Search Results for: Wallingford”
I also just added a non-custom taxonomy “All Categories” to see if the same behavior. It is. The selected item in the dropdown does not appear in Search Results title.
Trevor(Private) August 7, 2017 at 8:04 am #124764If I understand, you are trying to output at the top of the page what our search plugin has just searched for. This is possible, but quite complex and requires custom coding. It would be further complicated (and might not be possible) if you are using Ajax to update the search results, as the part of the page with the title might not be in the part of the page that the Ajax refreshes.
The more complex that your search is, the more difficult it will be to achieve what you want. The advantage of the standard WordPress approach, which Genesis uses, is that there is only one thing being searched for, a single search term or phrase, and only searched for with a simple text entry field.
I have provided other users with the basic code to get them started, but from there onwards would require custom coding, with which you would need to hire a 3rd party coder to help you.
We do intend to add a feature to the plugin to make this much simpler, possibly with the next major release, V3.
Some related previous threads:
https://support.searchandfilter.com/forums/topic/how-to-set-a-title-for-every-search/
https://support.searchandfilter.com/forums/topic/how-to-show-the-currently-selected-title-only/
https://support.searchandfilter.com/forums/topic/showing-the-search-query/
https://support.searchandfilter.com/forums/topic/results-displayed-results-count-searched-tag-associated-categories/Anonymous(Private) August 8, 2017 at 3:09 am #124945Okay, I understand simple vs. complex search now. Thank you for explaining. No, I am not running Ajax. I have been testing mainly just based on one item selected from one custom taxonomy, but the reality is there are at least three more options (from custom taxonomies) a person could choose as well, making the title of what I just searched for much more complex from a backend creation standpoint. It is an interesting issue that I did not consider beforehand. This is the first client need I have had for filtered results.
I guess there is the option of at least making the language show up a little friendlier, “Your Search Results:” (which implies looking below) So I can just change that.
Thank you so much for your help on this issue. You can close this thread.
-
AuthorPosts