Formatting *Homepage (only)* excerpts (1 post)

  1. altfgcom
    Posted 2 years ago #


    Trying to figure out if there is a way to

    a) remove from *homepage* excerpts anything within <h2><h3> headings.
    b) to have summary text formatted.

    Any assistance would be much appreciated.

    Note: Within posts, we use the "excerpt" box to specify the excerpt in the site's RSS feed. It's NOT the same as the homepage excerpt. Here's the code we have on the site's functions.php file:

    if (function_exists('add_filter'))
    add_filter('excerpt_length', 'my_excerpt_length');
    function my_excerpt_length($length) {
    if( is_home() ) {
    $length = 65;
    } else {
    $length = 3000;
    return $length;
    if (function_exists('add_filter'))
    add_filter('excerpt_length', 'new_excerpt_length');
    function new_excerpt_length($length) {
    if( is_archive() ) {
    $length = 100;
    return $length;
    function make_excerpt() {
    global $post;
    $text = $post->post_content;
    $text = strip_shortcodes( $text );
    $text = apply_filters('the_content', $text);
    $text = str_replace(']]>', ']]>', $text);
    $excerpt_length = 125;
    $text = wp_trim_words( $text, $excerpt_length );
    return $text;
    add_filter('the_excerpt', 'make_excerpt');

Topic Closed

This topic has been closed to new replies.

About this Topic