• I have this code in my funtions.php which allows me to add custom excerpts in posts.

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

    I want all excerpts to have a lot of the same info, like a list of:
    price/rrp/buy now etc.

    How can I get this text/info to auto display in the excerpt field in edit post instead of me manually typing them in for every post? (which I can then edit slightly per each post)

    Is it possible?

Viewing 1 replies (of 1 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    For new posts you can use this in your theme’s functions.php:

    add_filter( 'default_excerpt', 'extra_excerpt_content' );
    function extra_excerpt_content( $content ) {
      return $content  . '<span class="readmore"> <a href="[permalink]"> Read Review</a></span>';
    }
    
    add_filter('the_excerpt', 'do_shortcode');
    add_shortcode( 'permalink', 'add_post_permalink' );
    
    function add_post_permalink( $atts ){
     global $post;
     return get_permalink($post->ID);
    }

Viewing 1 replies (of 1 total)
  • The topic ‘Custom template in Excerpt field on edit post?’ is closed to new replies.