Yesterday I implemented a shortcode, but now my comments and related posts stop appearing.

The source of a rendered page now only displays

            <div class="posts-group">

instead of

    <div class="posts-group">          
      <div id="disqus_thread"></div>

    <div class="posts-group"><h2>Looking for more articles?</h2>

Now the only difference is the use of the shortcode, so the "bug" has to be there, right? Only problem is.. I see nothing wrong with it.

shortcode in functions.php:

function get_products($atts) {
  return ob_get_clean();
add_shortcode('products', 'get_products');

the block-products-inline template part:

    <p><i>Article continues below these four featured products!</i></p>

    <div class="posts-group inline-products">

        <h1>Featured store products</h1>

            <?php $catquery = new WP_Query( 'post_type=product&posts_per_page=4&orderby=rand' );
            while($catquery->have_posts()) : $catquery->the_post();

            <a href="<?php echo get_post_meta($post->ID,'PRODUCT-url', true);?>">
                <article class="post home-post homeproduct">
                        <div class="post-thumbnail-img inline-products-hover">
                            <?php the_post_thumbnail('small-thumbnail'); ?>
                            <?php the_title(); ?>
                            <?php the_content(); ?>

            <?php endwhile; ?>


I'm hoping someone else sees/finds my problem as I haven't got a clue.

  • Where is block-products-inline.php? What is the full path? Where are you using the shortcode? Is it inside the post content as typical?
    – s_ha_dum
    Jan 6, 2016 at 14:48
  • block-products-inline.php is in the root theme folder, shortcode is used inside the post content
    – vlovsky
    Jan 6, 2016 at 14:53
  • Are you getting any errors?
    – s_ha_dum
    Jan 6, 2016 at 15:04

1 Answer 1


This is a bit of a guess, but you are running a secondary query inside the Loop (by way of the shortcode). That is going to alter some variables that subsequent code may depend upon, such as $post.

I am thinking that you need to add wp_reset_query(); after your secondary Loop in the shortcode-- right after the endwhile;


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.