I am working with a plugin that provides a shortcode with only a couple of parameters. I'm using [list-shows] shortcode. I would like to also pull in an excerpt of the content.

I was able to add in the thumbnail to the output, but not the content, which seems to be referred to in the atts of the other shortcodes as show_desc. You can see the output on this page

Here is the code for the shortcode. Apologies for my ignorance. Learning curve.

 * Shortcode for displaying a list of all shows * Since 2.0.0 
function station_shortcode_list_shows($atts) {
        'genre' => '',
        'show_desc' => 1
                    ), $atts));

    //grab the published shows
    $args = array(
        'numberposts' => -1,
        'offset' => 0,
        'orderby' => 'title',
        'order' => 'ASC',
        'post_type' => 'show',
        'post_status' => 'publish',
        'meta_query' => array(
                'key' => 'show_active',
                'value' => 'on',

    if ($genre != '') {
        $args['genres'] = $genre;

    $shows = get_posts($args);

    //if there are no shows saved, return nothing
    if (!$shows) {
        return false;

    $output = '';

    $output .= '<div id="station-show-list">';
    $output .= '<ul>';
    foreach ($shows as $show) {

        $output .= '<li>' . get_the_post_thumbnail($show->ID, 'thumbnail') . '<a href="' . get_permalink($show->ID) . '">' . get_the_title($show->ID) . '</a></li>';

        $output .= '</li>';
    $output .= '</ul>';
    $output .= '</div>';
    return $output;

1 Answer 1


If you have a look at how [dj-widget] shortcode is handled you will get an idea of how to implement plugin authors' idea of showing post description.

            if($show_desc) {
                $desc_string = station_shorten_string(strip_tags($show->post_content), 20);
                $output .= '<span class="on-air-show-desc">'.$desc_string.'</span>';

insert this between $output .= '<li>...' and $output .= '</li>';

Please NOTE: There might be a better way to show actual post excerpt instead trying to generate one based on post content. More here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.