• Resolved KKSL

    (@kendrajk)


    I’m still in the testing phase with this plugin on my site but when I included [post_excerpt] shortcode, no text was shown where it should be in the email I received.


    On my site, it’s creating excerpts itself, I’m not adding them to the “excerpt” space on a post. Is that an issue? I am also using a function on my site to customize the look of excerpts. Is there something I need to add to that to make this plugin recognize my excerpts maybe?
    Thanks.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Hi @kendrajk,
    Thanks for your message.

    Does it work if you manually include an excerpt for the post as opposed to an automatic one?

    Thread Starter KKSL

    (@kendrajk)

    Yes it does work if I put in a manual excerpt. Is there anyway around that so it can grab the automatic excerpt instead?

    Hi @kendrajk,
    As far as I know it should work.
    Can you share the code for your excerpt?

    Thread Starter KKSL

    (@kendrajk)

    Here’s what I’m using for the excerpt.

    function wpse_allowedtags() {
    // Add custom tags to this string
    return '<script>,<style>,<br>,<em>,<i>,<ul>,<ol>,<li>,<a>,<p>,<strong>,<em>';
    }

    if ( ! function_exists( 'wpse_custom_wp_trim_excerpt' ) ) :

    function wpse_custom_wp_trim_excerpt($wpse_excerpt) {
    global $post;
    $raw_excerpt = $wpse_excerpt;
    if ( '' == $wpse_excerpt ) {

    $wpse_excerpt = get_the_content('');
    $wpse_excerpt = strip_shortcodes( $wpse_excerpt );
    $wpse_excerpt = apply_filters('the_content', $wpse_excerpt);
    $wpse_excerpt = str_replace(']]>', ']]&gt;', $wpse_excerpt);
    $wpse_excerpt = strip_tags($wpse_excerpt, wpse_allowedtags()); /*IF you need to allow just certain tags. Delete if all tags are allowed */

    //Set the excerpt word count and only break after sentence is complete.
    $excerpt_word_count = 45;
    $excerpt_length = apply_filters('excerpt_length', $excerpt_word_count);
    $tokens = array();
    $excerptOutput = '';
    $count = 0;

    // Divide the string into tokens; HTML tags, or words, followed by any whitespace
    preg_match_all('/(<[^>]+>|[^<>\s]+)\s*/u', $wpse_excerpt, $tokens);

    foreach ($tokens[0] as $token) {

    if ($count >= $excerpt_word_count && preg_match('/[\,\;\?\.\!]\s*$/uS', $token)) {
    // Limit reached, continue until , ; ? . or ! occur at the end
    $excerptOutput .= trim($token);
    break;
    }

    // Add words to complete sentence
    $count++;

    // Append what's left of the token
    $excerptOutput .= $token;
    }

    $wpse_excerpt = trim(force_balance_tags($excerptOutput));


    return $wpse_excerpt;

    }
    return apply_filters('wpse_custom_wp_trim_excerpt', $wpse_excerpt, $raw_excerpt);
    }

    endif;

    remove_filter('get_the_excerpt', 'wp_trim_excerpt');
    add_filter('get_the_excerpt', 'wpse_custom_wp_trim_excerpt');


    Thanks @kendrajk,
    Does it work if you don’t use your custom code, i.e. comment out the remove_filter and add_filter lines?

    Thread Starter KKSL

    (@kendrajk)

    Yes it does work if I take the function out. Is there any way to make it work WITH the function? Thanks.

    Hi @kendrajk,
    You may wish to investigate your function as something in your code is causing it to not show.
    I would start by making it as simple as possible at first, then adding complexity until you find the issue.

    Let me know how you get on.

    Closing due to inactivity. If you need further help with this, please feel free to re-open this thread.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Does post_excerpt shortcode grab from manual excerpt or default?’ is closed to new replies.