Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

In a site that uses Bones theme, I am trying to localize the search results page and would like to replace the "read more" text with something else. I tried editing the search.php but it is useless as the search.php seems to have a bug (It calls the_excerpt function with parameters while the function does not take any).

I also tried the filter hook as described in the function reference but could not make it work, perhaps because I could not call the new function as required.

I am quite new to wordpress and php, yes, but I feel there should be an easier way to replace that text. Are there any suggestions?

share|improve this question

2 Answers 2

Filter 'the_excerpt' on the search page only:

add_filter( 'the_excerpt', 'wpse_99415_search_excerpt' );

function wpse_99415_search_excerpt( $excerpt )
{
    if ( ! is_search() )
        return $excerpt;

    global $post;

    // create a custom excerpt

    return $custom_excerpt;
}
share|improve this answer
    
Sorry, I did not get that. What goes where? –  turzifer May 14 '13 at 13:18
    
Add the code to your child theme’s functions.php or to a custom plugin. –  toscho May 14 '13 at 13:19
    
Yes, and then how do I call that? –  turzifer May 14 '13 at 13:25
    
add_filter( 'the_excerpt' ) will be used on all excerpts automatically then. –  toscho May 14 '13 at 13:27

Yeah that theme is wrong. I just installed it myself. The excerpt() takes no parameters according to the codex.

Other alternatives are:

  1. Add the link your self.

    < a href =" < ?php the_permalink();" >My text here< /a>

  2. Switch from using the excerpt function to the content() function.

    < ?php the_content("My Text Here"); ?>

If you use the_content function in your posts, you will need to add the "Insert More Tag" in your post content.

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.