-
AuthorPosts
-
October 20, 2018 at 3:55 pm #1024349
Hi guys
My goal is to fully customize/change all the labels on the Enfold search result page.
So far, I managed to change the following:
1) Title and paragraph above the search input field in the file search.php
2) Placeholder text for the search if clicked in the header in the file searchform.php
3) “No search results” title and search tips below it in the file loop-search.phpThe only thing which is missing and that I could not find so far is the h4 title “search results for: [search term]”.
Which file do I have to edit in order to change this label?Thanks a lot and best regards
MichaelOctober 20, 2018 at 6:02 pm #1024374Hey Michael,
I searched the theme for “search results for” here are the results:
line 607 in \enfold\config-woocommerce\config.php
line 1072 & 1083 in \enfold\framework\php\function-set-avia-frontend.php
line 446 in \enfold\framework\php\class-breadcrumb.phpI’m thinking line 1072 & 1083 are the ones you want, but the other ones will be helpful too :)
Best regards,
MikeOctober 20, 2018 at 6:18 pm #1024376Hi Mike
Thanks a lot! I just changed the label in all three files, emptied browser cache etc. – no change unfortunately.
Is this label hidden somewhere else?Best regards and thanks
MichaelOctober 20, 2018 at 6:36 pm #1024378October 20, 2018 at 6:58 pm #1024382Changed this one as well now – still no change.
No idea how you made this numbers in there. In my case, the default string just won’t change no matter what I write in the files of my child theme.October 20, 2018 at 7:05 pm #1024386Found this string in all the language files in the lang folder.
Do I have to change it there and if yes, in which folder?EDIT: The lang folder is a bit confusing to me anyway. I see .mo and .po files, but also one file called enfold.pot which is MS PowerPoint template?
- This reply was modified 6 years, 2 months ago by michaelH. Reason: Added comment about .mo and .po files
October 20, 2018 at 7:12 pm #1024391Hi,
Sorry, I edited the file directly, to add this to your child theme you will need to add this function to your child theme functions.php:if(!function_exists('avia_which_archive')) { /** * checks which archive we are viewing and returns the archive string */ function avia_which_archive() { $output = ""; if ( is_category() ) { $output = __('Archive for category:','avia_framework')." ".single_cat_title('',false); } elseif (is_day()) { $output = __('Archive for date:','avia_framework')." ".get_the_time( __('F jS, Y','avia_framework') ); } elseif (is_month()) { $output = __('Archive for month:','avia_framework')." ".get_the_time( __('F, Y','avia_framework') ); } elseif (is_year()) { $output = __('Archive for year:','avia_framework')." ".get_the_time( __('Y','avia_framework') ); } elseif (is_search()) { global $wp_query; if(!empty($wp_query->found_posts)) { if($wp_query->found_posts > 1) { $output = $wp_query->found_posts ." ". __('search results for:','avia_framework')." ".esc_attr( get_search_query() ); } else { $output = $wp_query->found_posts ." ". __('search result for:','avia_framework')." ".esc_attr( get_search_query() ); } } else { if(!empty($_GET['s'])) { $output = __('Search results for:','avia_framework')." ".esc_attr( get_search_query() ); } else { $output = __('To search the site please enter a valid term','avia_framework'); } } } elseif (is_author()) { $curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author')); $output = __('Author Archive','avia_framework')." "; if(isset($curauth->nickname) && isset($curauth->ID)) { $name = apply_filters('avf_author_nickname', $curauth->nickname, $curauth->ID); $output .= __('for:','avia_framework') ." ". $name; } } elseif (is_tag()) { $output = __('Tag Archive for:','avia_framework')." ".single_tag_title('',false); } elseif(is_tax()) { $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); $output = __('Archive for:','avia_framework')." ".$term->name; } else { $output = __('Archives','avia_framework')." "; } if (isset($_GET['paged']) && !empty($_GET['paged'])) { $output .= " (".__('Page','avia_framework')." ".$_GET['paged'].")"; } $output = apply_filters('avf_which_archive_output', $output); return $output; } }
change the 3 places that “Search results for” are
I tested this on my localhost with a child theme and it worked.Best regards,
MikeOctober 20, 2018 at 7:21 pm #1024395Hi Mike
Sorry my bad – I should mentioned earlier that I am using a child theme.
But woohoo, it worked nicely with that “little” snippet. Pretty huge function just for changing one string on one page, but it works which is why I am happy about it.You may close this thread now please.
Thanks a lot and best regards
MichaelOctober 20, 2018 at 7:41 pm #1024397Hi,
Another option would be to use this function:function custom_results(){ ?> <script> jQuery(window).load(function(){ jQuery(".template-search h4.extra-mini-title.widgettitle").text("Your Results"); }); </script> <?php } add_action('wp_footer', 'custom_results');
but it replaces all of the text in the line, perhaps it will work for your situation.
Best regards,
MikeOctober 23, 2018 at 3:37 pm #1025474Hi Mike
Thanks a lot for providing another option.
I will check it out.Please close this thread now.
Best regards and thanks
MichaelOctober 24, 2018 at 3:23 am #1025762Hi,
Glad we were able to help, we will close this now. Thank you for using Enfold.For your information, you can take a look at Enfold documentation here
For any other questions or issues, feel free to start new threads under Enfold sub forum and we will gladly try to help you :)Best regards,
Mike -
AuthorPosts
- The topic ‘Fully customize labels on the search result page’ is closed to new replies.