I'm trying to implement a slider in my Wordpress post. For this I'm using Meta Slider plugin. When I've added a slider, I should be able to use the shortcode in my posts ([metaslider id=21]). If I add this to one of my post, it shows up the same way on the live page. I don't see any slider, there is just a string "[metaslider id=21]" on my page.

I checked that wp_footer(); is implemented right before the body tag is ending and that the footer is implemented in every php file.

I get the post content using this way:

$args = array('posts_per_page' => 5, 'tag' => get_the_title());
$wp_query = new WP_Query( $args );
$posts = $wp_query->get_posts();

foreach($posts as $post){
    $id = $post->ID;
    $content = get_post($id);

    echo $content->post_content;

It gets the content perfectly but it's not loading the slider.

Can someone please tell me the reason why?

1 Answer 1


You need to run the content through do_shortcode() - at the moment you're just echo'ing the raw post content, so nothing gets parsed.

echo do_shortcode( $content->post_content );

However, you might be better off implementing a proper "loop" and using the_content() template tag - doing so will ensure everything runs "as normal" (firing all the typical hooks and formatting filters), accommodating for any quirks/extra hooks your slider plugin might rely on:

while ( $posts->have_posts() ) {

wp_reset_postdata(); // Restore the global post to the "current" post

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.