Add content to PHP WP excerpt

I’m a complete PHP newbie and I need a solutionto get the most out of this stupid problem with a custom WordPress theme.

I found the part where excerpts to on index page are ‘made’ and all I need is to add "..." to the end of this part.

Read More
<?php 

echo wpautop(
    $post->post_excerpt 
    ? $post->post_excerpt 
    : athemes_limit_string(strip_tags($post->post_content), 200) 
); 

?>

I tried to add them after this line, but they showed up after the break, but I want them inline.

Related posts

Leave a Reply

2 comments

  1. There are better ways of doing this, but to answer your question:

    echo wpautop( $post->post_excerpt ? $post->post_excerpt : athemes_limit_string(strip_tags($post->post_content), 200).'...' );
    
  2. In PHP you can add anything you want in the HTML by doing it outside of PHP, that here is after the ending ?> marker:

    [...] ?> ...
    

    Compare: http://php.net/language.basic-syntax.phpmode

    I’d say that is the most simple and flexible method when you’re concerned about themeing. The second suggestion I would give is to add it as a string to the echo, works by using a comma (,):

    echo wpautop( $p ... nt), 200) ), '...';
                                    ^^^^^^^
    

    Compare: http://php.net/echo , http://php.net/string

    The function in WordPress for this btw is the_excerpt() and if you modify a theme, you should just hook in that. Looks like the custom theme you’ve got is doing things out of the lines. The the_excerpt function btw. add that on it’s own, you don’t need to care.