Support » Plugin: WP Bootstrap Carousel » Captions

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Peter J. Herrel

    (@donutz)

    Hi @paulmyatt, assuming you’re using the display posts shortcode addon, querying image attachments, you should be able to display captions by setting the include_excerpt parameter to true:

    [display-posts post_type="attachment" id="4,7,10" include_excerpt="true" bootstrap="1"]

    Thanks but I’m not using the display posts addon. I just want to output the image title and caption as set in the image’s meta data in the WP media library.

    Plugin Author Peter J. Herrel

    (@donutz)

    @paulmyatt, by default the attachment description (post content) is displayed, and I guess — as your Q indicates — it might be a good idea to implement an option to display the caption (post excerpt) instead. For now, you can use the wp_bootstrap_carousel_caption_text filter hook to modify the default. Put the following in your functions.php file:

    add_filter( 'wp_bootstrap_carousel_caption_text', 'myatt_wp_bootstrap_carousel_caption_text', 10, 2 );
    function myatt_wp_bootstrap_carousel_caption_text( $text, $item_id )
    {
        $post = get_post( $item_id );
        $excerpt = $post->post_excerpt;
    
        if( ! empty( $excerpt ) )
            return wpautop( wptexturize( $excerpt ) );
    
        return $text;
    }

    That worked perfectly, many thanks!

    Plugin Author Peter J. Herrel

    (@donutz)

    You’re welcome. As I said, I think it makes more sense to include the caption by default, rather than the description, because space is limited and the caption/excerpt is generally shorter than the description/content. I’ll open a ticket for this, and it should be implemented by the next release. I’ll tag you in this thread if it’s done, and after upgrading you can delete the custom function.

    Plugin Author Peter J. Herrel

    (@donutz)

    @paulmyatt version 0.4.0 is out in the wild, you can safely delete the function after upgrading

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Captions’ is closed to new replies.