WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] the_excerpt - need help with filters (2 posts)

  1. antishape
    Member
    Posted 2 years ago #

    Hello,

    I need help with the_excerpt filters. Here's the code I have right now in the functions.php

    function new_excerpt_length($length) {
    	return 75;
    }
    add_filter('excerpt_length', 'new_excerpt_length');
    function excerpt_read_more_link($output) {
     global $post;
     return $output . '<a href="'. get_permalink($post->ID) . '"> read more...</a>';
    }

    In my opinion it doesn't make sense to have [...] right after the 75 words and below a link to read more. I want the "read more" link instead of [...] and tried to add right after the code above:

    function new_excerpt_more($more) {
    	return '<a href="'. get_permalink($post->ID) . '"> read more...</a>';
    }
    add_filter('excerpt_more', 'new_excerpt_more');

    But turns out it's wrong. Any idea how to do it the right way? Thanks!

  2. NateJacobs
    Member
    Posted 2 years ago #

    function xyz_new_excerpt_more($more)
    {
    	return '<a class="read_more" href="'. get_permalink($post->ID) . '">' . 'Read More' . '</a>';
    }
    add_filter('excerpt_more', 'xyz_new_excerpt_more');

Topic Closed

This topic has been closed to new replies.

About this Topic