Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author lebasca

    (@lebasca)

    Hi John S,

    Please follow these steps:
    1. Open your theme’s functions.php file.
    2. Add the following code:
    function better_trim_excerpt($text)
    {
    $raw_excerpt = $text;
    if ( ” == $text ) {
    $text = get_the_content(”);
    $text = strip_shortcodes( $text );
    $text = apply_filters(‘the_content’, $text);
    $text = str_replace(‘]]>’, ‘]]>’, $text);

    // Removes any JavaScript in posts (between <script> and </script> tags)
    $text = preg_replace(‘@<script[^>]*?>.*?</script>@si’, ”, $text);

    // Enable formatting in excerpts – Add HTML tags that you want to be parsed in excerpts, default is 55
    $text = strip_tags($text, ‘<strong><b><em><i><a><code><kbd><ul><li>‘);

    // Set custom excerpt length – number of words to be shown in excerpts
    $excerpt_length = apply_filters(‘excerpt_length’, 55);

    // Modify excerpt more string at the end from […] to …
    $excerpt_more = apply_filters(‘excerpt_more’, ‘ ‘ . ‘…’);

    $words = preg_split(“/[\n\r\t ]+/”, $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY);
    if ( count($words) > $excerpt_length ) {
    array_pop($words);
    $text = implode(‘ ‘, $words);

    // IMPORTANT! Prevents tags cutoff by excerpt (i.e. unclosed tags) from breaking formatting
    $text = force_balance_tags( $text );

    $text = $text . $excerpt_more;
    } else {
    $text = implode(‘ ‘, $words);
    }
    }
    return apply_filters(‘wp_trim_excerpt’, $text, $raw_excerpt);
    }

    // Remove the native excerpt function, and replace it with the improved function
    remove_filter(‘get_the_excerpt’, ‘wp_trim_excerpt’);
    add_filter(‘get_the_excerpt’, ‘better_trim_excerpt’);

    However, my plugin disables the formatting of the markup ul. So, I will need to release another version but it will take me sometime because I am working in other projects by now.

    Hope this helps you in the meantime,
    Lebasca

    Thread Starter jscreativedesigns

    (@jscreativedesigns)

    Hi Lebasca!

    Thank you for your help!

    For some reason, I’m getting syntax errors on lines 304 & 310 – I tried singling out and fixing the issue, to no avail. Any help would be much appreciated!

    I appreciate you looking into this. Thank you for your hard work.

    // John S

    Plugin Author lebasca

    (@lebasca)

    Hi John S,

    Are you talking about the code lines of the function better_trim_excerpt or other functions in your functions.php file? What is the code for the lines 304 & 310?

    Let me know to be able to help you,
    Lebasca

    Thread Starter jscreativedesigns

    (@jscreativedesigns)

    Hi Lebasca –

    I’m just getting a ‘syntax’ error – when I upload the php file (functions.php) to the server, it ‘breaks’ wordpress – meaning, it recognizes an illegal character within the file and won’t allow me to move any further.

    here is a link to a screenshot I’ve taken:

    Thank you for your help! Myself and my client appreciate it greatly.

    Plugin Author lebasca

    (@lebasca)

    Hi John S,

    When you copied and pasted the function code that I provided you, it transformed this character “>” to a HTML character “&gt”.
    Please change the symbol &gt by > in the line 304. That line should looks like this:
    if ( count($words) > $excerpt_length ) {

    If you have any more issues, just let me know but I’m sure it should solve your issue,

    Lebasca

    Thread Starter jscreativedesigns

    (@jscreativedesigns)

    Hi Lebasca –

    I edited the code – thank you very much!

    It still did not SEEM to fix the issue –

    Please see:
    https://www.gricegroupllc.com/?page_id=110

    vs.

    https://www.gricegroupllc.com/?p=425

    Plugin Author lebasca

    (@lebasca)

    Hi John S,

    It doesn’t work because when you copied and pasted the code, it transformed the character ‘<‘ and ‘>’ in HTML codes (‘&lt’ and ‘&gt’).

    Compare the function that I posted with your function file and change it manually. I see errors in the line 292 and 294

    Regards,
    Lebasca

    Plugin Author lebasca

    (@lebasca)

    Hi John S,

    A new version of this plugin was released. So, your ul and li in your post will show the format now.

    Regards,
    Lebasca

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Show Post formatting IN the columns’ is closed to new replies.