Post excerpts in Pinboard

Viewing 6 posts - 1 through 6 (of 6 total)
  • #17157
    mark9
    Participant

    I posted first about this in “How to Customize the Theme’s Content Area” topic but then realised it would be more helpful it separately.
    I really appreciate Daniel’s help, he’s been so helpful! Here is a copy of my first two posts in that original topic:

    mark9
    Hi Daniel,
    I have my posts displayed in 4 columns. Everything looks great, am really happy with your theme. Just one thing I can not resolve and wonder if there are any options available to make it to work. I constantly use shortcodes in my posts [like for example a shortcode for a Like/Dislike button]. In posts excerpts all shortcodes are ignored. Is it be possible for them to be recognised somehow?
    Thanks in advance.
    Mark

    Daniel Tara
    Add this to your functions.php file:
    add_filter( ‘the_excerpt’, ‘do_shortcode’ );

    mark9
    Daniel, I can’t even tell you how impressed I’m with your products and with the way you conduct you business. I’ve tried more than 20 different themes and honestly, I wouldn’t put them even close [even deactivated] to your one. Then you replied just few hours after I submitted my question! What can I say – top notch stuff!
    Man, it didn’t work. Unfortunately.
    It still ignores my shortcodes. I use 2 of them – one for a table from Tablepress and one for Like buttons from Likebtn.
    I put that line you recommended right below this [at the very bottom of functions.php]:
    if ( ! function_exists( ‘pinboard_copyright_notice’ ) ) :
    /**
    * Display notification no posts were found
    *
    * @since Pinboard 1.0
    */
    function pinboard_copyright_notice() {
    $copyright = pinboard_get_option( ‘copyright_notice’ );
    $copyright = str_replace( ‘%year%’, date( ‘Y’ ), $copyright );
    $copyright = str_replace( ‘%blogname%’, get_bloginfo( ‘name’ ), $copyright );
    echo esc_html( $copyright );
    }
    endif;
    Thanks a zillion!
    Mark

    Daniel Tara
    You are probably not using a custom excerpt but have it generated automatically. In this case shortcodes are stripped automatically by WordPress. You can either add a custom excerpt for each post or add this code in functions.php:
    remove_filter( ‘get_the_excerpt’, ‘wp_trim_excerpt’ );
    add_filter( ‘get_the_excerpt’, ‘pinboard_trim_excerpt’ );

    function pinboard_trim_excerpt($text = ”) {
    $raw_excerpt = $text;
    if ( ” == $text ) {
    $text = get_the_content(”);

    $text = apply_filters(‘the_content’, $text);
    $text = str_replace(‘]]>’, ‘]]>’, $text);
    $excerpt_length = apply_filters(‘excerpt_length’, 55);
    $excerpt_more = apply_filters(‘excerpt_more’, ‘ ‘ . ‘[…]’);
    $text = wp_trim_words( $text, $excerpt_length, $excerpt_more );
    }
    return apply_filters(‘wp_trim_excerpt’, $text, $raw_excerpt);
    }

    #17159
    mark9
    Participant

    My last post in that original topic before starting posting in this one.

    Mark9
    Thanks a lot Daniel. You are soooo helpful! I thought it would more beneficial to have it as a separate topic, so I’ve just moved our conversation to

    Till today I knew nothing about custom excerpt, functions.php and all other things. Didn’t even know that WP
    1] strips out all HTML and images
    2] truncates your post to 55 words
    3] adds this to the end of the text: “[…]“

    [the first item is my main problem, isn’t it?] I don’t know PHP and HTML but have just started educating myself with what is a a custom excerpt and how to create it.
    I put in functions.php your recommended code, now I can see the text inside those shortcodes published but they are not read as HTML commands.
    🙁
    Back to my topic

    #17160
    mark9
    Participant

    I came across an interesting article about WordPress Post Excerpts

    Daniel, can your additional code fix the 55 words thing and “[…]“? To make it unlimited in length and no “[…]“. But the main thing of course – to make it to read HTMLs
    May be there is a plugin that can do this?
    That article above says:
    “In the theme, theme developers have access to the the_excerpt() template tag. If you have filled in the excerpt box, WP displays your custom excerpt”
    Can not say I know what that means but your extra code did just that, isn’t it?

    Thanks a lot for your time! To say that you are the best – that not to say anything.

    Kind Regards,

    Mark

    #17161
    Daniel Tara
    Keymaster

    You need to also keep the line that I mentioned in the first post:

    add_filter( ‘the_excerpt’, ‘do_shortcode’ );

    For what you’re looking for you may want to replace excerpts with content alltogether. Please see this post which explains how to do that.

    #17163
    mark9
    Participant

    Thanks Daniel. I would like everything to be displayed in 3 [and better in 4 columns]. With excerpts I should be able to achieve that but with content – most likely not, it’s probably going to be 1 column, isn’t it?
    I wasn’t sure about the order – so tried both codes in a different order [but both time at the very end of the functions.php] – same thing, all shortcodes are read as if they are simple text.

    #17164
    mark9
    Participant

    This plugin has solved all probs:

    So far so good – exactly what I was after. Thanks a lot Daniel. Pinboard is the best WP theme on this planet!

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.