Forums

Advanced Excerpt
Feature Request - Option for both Auto & Existing Excerpt (4 posts)

  1. cswake
    Member
    Posted 1 year ago #

    Asking for an option to automatically generate an excerpt from Posts or to use the existing excerpt and format it the same way as the auto-generated excerpt.

    ie. If a post has no excerpt, then auto-generate 13 word excerpt. If a post has an excerpt, then just show the first 13 words of the existing excerpt.

    http://wordpress.org/extend/plugins/advanced-excerpt/

  2. archon810
    Member
    Posted 1 year ago #

    I have a similar request, I think - is it possible to detect the manual excerpts (such as ones using <!--more--> from http://codex.wordpress.org/Customizing_the_Read_More) and still output whatever the Read More option outputs? Otherwise, for content with custom excerpts, we end up without the Read More link at all.

    Thank you.

  3. alpha_llama
    Member
    Posted 1 year ago #

    I wanted all my 'teasers' to look the same on my front page whether the posts have <!--more--> tags, custom excerpts, or none at all. So I wrote the following code:

    <?php
    /* Continue Reading Stuff */
    
    function my_continue_reading_link() {
      return ' Read the rest of this entry »';
    }
    
    function my_auto_excerpt_more( $more ) {
      return ' . . .' . my_continue_reading_link();
    }
    
    function my_custom_excerpt_more( $excerpt ) {
      if ( has_excerpt() && ! is_attachment() ) {
        $excerpt .= my_continue_reading_link();
      }
      return $excerpt;
    }
    
    function my_the_excerpt() {
      if( has_excerpt() ) {
        // Post has a custom excerpt
        return get_the_excerpt();
      } else {
        if( strpos( get_the_content(),"class=\"more-link\"" ) ){
          // Post has <!--more--> link
          return the_content( my_continue_reading_link() );
        } else {
          // Post does not have <!--more--> link
          return get_the_excerpt();
        }
      }
    }
    
    // Init Filters to make it all work
    function read_more_filters() {
      add_filter( 'excerpt_more', 'my_auto_excerpt_more' );
      add_filter('get_the_excerpt','my_custom_excerpt_more');
      add_filter('the_excerpt','my_the_excerpt');
    }
    add_action('after_setup_theme','read_more_filters');
    
    
  4. alpha_llama
    Member
    Posted 1 year ago #

    So just to be clear, they all look like this now:

    Read the rest of this entry »

    with thre periods on the end of the auto-generated (eg; no custom excerpt or more tag posts.)

    Hope that helps.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic