• bondigor69

    (@bondigor69)


    hey guys I want to add the post title after the read more in the excerpt

    function excerpt_read_more_link($output) {
     global $post;
     return $output . '<a href="'. get_permalink($post->ID) . '"> Read More...</a>';
    }
    add_filter('the_excerpt', 'excerpt_read_more_link');

    I tried
    <php post title ….. and many more please help

Viewing 8 replies - 1 through 8 (of 8 total)
  • Michael

    (@alchymyth)

    try:

    return $output . '<a href="'. get_permalink($post->ID) . '"> Read More of ' . get_the_title($post->ID) . '</a>';

    or:

    return $output . '<a href="'. get_permalink($post->ID) . '"> Read More of ' . $post->post_title . '</a>';
    Thread Starter bondigor69

    (@bondigor69)

    thank you so much it works but how can I put the read more link right after the excerpt not underneath of it

    thank you in advance

    Michael

    (@alchymyth)

    untested, try:

    function excerpt_read_more_link($output) {
     global $post;
     if($post->post_excerpt) : //provision for manual excerpt
       return $output . '<a href="'. get_permalink($post->ID) . '"> Read More of ' . $post->post_title . '</a>';
     else:
       return substr($output,0,-5).'<a href="'. get_permalink($post->ID) . '"> Read More of ' . $post->post_title . '</a></p>';
     endif;
    }
    add_filter('the_excerpt', 'excerpt_read_more_link');
    Thread Starter bondigor69

    (@bondigor69)

    It dosent work i get blank pages( so I had to remove this code)
    and put back my previous one

    function excerpt_read_more_link($output) {
     global $post;return $output . '[...] Read More of <a href="'. get_permalink($post->ID) . '"> ' . get_the_title($post->ID) . '</a>';
    }
    add_filter('the_excerpt', 'excerpt_read_more_link');

    Thread Starter bondigor69

    (@bondigor69)

    lol sorry it works perfectly.
    The problem was the code that you sent me was formatted im my email so I took the code directly from this thread.

    heehee thank you man

    Thread Starter bondigor69

    (@bondigor69)

    Another problem.
    If I leave the auto excerpt the read more link is following the excerpt.
    But if I write my own excerpt the read more link goes underneath the excerpt like if there’s a new line or paragraph?? weird
    can you help me again please

    Michael

    (@alchymyth)

    But if I write my own excerpt the read more link goes underneath the excerpt like if there’s a new line or paragraph?? weird

    this was the reason for the conditional section in the last suggested code – because a manual excerpt can have any kinds of html tags at the end, simply replacing the last characters (usually the closing paragraph tag </p>) won’t work.

    however, if you don’t have anything else than simple paragraphs or text at the end of your manual excerpt, simply try to work with this code:

    function excerpt_read_more_link($output) {
     global $post;
       return substr($output,0,-5).'<a href="'. get_permalink($post->ID) . '"> Read More of ' . $post->post_title . '</a></p>';
    }
    add_filter('the_excerpt', 'excerpt_read_more_link');
    Thread Starter bondigor69

    (@bondigor69)

    GREAT
    thank you it works

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘How to excerpt’ is closed to new replies.