Featured Story Shortcode not outputting content


So I’m trying to get a shortcode working where it calls the posts in the featured story category but I’m having issue getting it to output even just the title from the post. There’s no error on the page. But there’s nothing else showing either but white space between the nav and footer.

function featured_story() {
    $args = array(
        'posts_per_page' => 5,
        'category_name' => 'featured_story'

    $last_5_posts_query = new WP_Query( $args );
    while($last_5_posts_query->have_posts()) :
        $title = get_the_title();

        $content .= '<div class="featured-stories">';
        $content .= '<h3>' .$title. '</h3>';


return $content;

add_shortcode( 'featured-story', 'featured_story' );

ladyc 2 months 0 Answers 14 views 0

Leave an answer