Support » Theme: MesoColumn » Caption text appearing as first line in article excerpts

  • Resolved vortex25

    (@vortex25)


    Hi,
    When I add a caption to a featured image, the text then becomes the first line of the article excerpt which makes the sentence read as nonsense.

    However, when opening into the article itself, it reads normally and the caption is no longer in the first sentence – only on the previous page as part of the excerpt.

    Please could anyone advise ?

    Many thanks!

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Theme Author Richie KS

    (@rkcorp)

    open lib/functions/theme-functions.php and edit the functions dez_get_custom_the_excerpt() to

    function dez_get_custom_the_excerpt($limit='',$more='') {
    global $post;
    if($limit == 'disable' || $limit == '0') {
    $excerpt = '';
    
    } else {
    
    $thepostlink = '<a class="readmore" href="'. get_permalink() . '" title="' . the_title_attribute('echo=0') . '">';
    $custom_text = get_post_field('post_excerpt',$post->ID);
    $all_content = get_the_content();
    //Regular expression that strips the header tags and their content.
    $regex = '#(<h([1-6])[^>]*>)\s?(.*)?\s?(<\/h\2>)#';
    $content = preg_replace($regex,'', $all_content);
    
    //if use manual excerpt
    if($custom_text) {
    if($more) {
        $excerpt = $custom_text . $thepostlink . $more . '</a>';
        } else {
        $excerpt = $custom_text;
        }
    
    } else {
    
    //check if its chinese character input
    $chinese_output = preg_match_all("/\p{Han}+/u", $post->post_content, $matches);
    if($chinese_output) {
    
    if($more) {
    $excerpt = mb_substr( get_the_excerpt(), 0, $limit*2 ) . '...' . $thepostlink . $more.'</a>';
    } else {
    $excerpt = mb_substr( get_the_excerpt(), 0, $limit*2 ) . '...';
    }
    
    } else {
    
    //remove caption tag
    $content_filter_cap = strip_shortcodes( $content );
    //remove email tag
    $pattern = "/[^@\s]*@[^@\s]*\.[^@\s]*/";
    $replacement = "";
    $content_filter = preg_replace($pattern, $replacement, $content_filter_cap);
    
    if($more) {
        $excerpt = wp_trim_words($content_filter, $limit) . $thepostlink.$more.'</a>';
        } else {
        $excerpt = wp_trim_words($content_filter, $limit);
        }
    }
    }
    }
    return apply_filters('meso_get_custom_excerpt',$excerpt);
    }
    vortex25

    (@vortex25)

    That’s great – many thanks for your help !!

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.