Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #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.php

    The 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
    Michael

    #1024374

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

    I’m thinking line 1072 & 1083 are the ones you want, but the other ones will be helpful too :)

    Best regards,
    Mike

    #1024376

    Hi 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
    Michael

    #1024378

    Hi,
    Opps, there was also one at line 1076 in \enfold\framework\php\function-set-avia-frontend.php
    But I tested by adding the line numbers to the text and for a “no result search” line 1083 shows:
    2018-10-20-123338
    For a successful search line 1072 shows:
    2018-10-20-123541

    Best regards,
    Mike

    #1024382

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

    #1024386

    Found 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
    #1024391

    Hi,
    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,
    Mike

    #1024395

    Hi 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
    Michael

    #1024397

    Hi,
    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,
    Mike

    #1025474

    Hi Mike

    Thanks a lot for providing another option.
    I will check it out.

    Please close this thread now.

    Best regards and thanks
    Michael

    #1025762

    Hi,
    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

Viewing 11 posts - 1 through 11 (of 11 total)
  • The topic ‘Fully customize labels on the search result page’ is closed to new replies.