• Resolved sventy5

    (@sventy5)


    Hi Richie,

    I have another question: How I can show custom excerpts in the Slider, the Home Featured Posts and the archives? Is there any way to override the auto excerpts? As you can see on https://hallunkenblatt.de/ there are the picture captions in the excerpts, I want to get rid of that. I already wrote a custom excerpt in the post options, but that doesn’t seem wo work.

    Best regards

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

    (@rkcorp)

    try open lib/functions/theme-functions.php edit line 373+, find this code

    function dez_get_custom_the_excerpt($limit=”,$more=”) {

    }

    edit 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);
    }

    this should allow you to use the manual excerpt in posting.

    Thread Starter sventy5

    (@sventy5)

    Hi Richie, many many thanks for your efforts, it worked perfectly ??

    Best regards

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to show custom excerpt’ is closed to new replies.