I’m actually trying to display the post thumbnail inside the loop just before the content by using the_post_thumbnail(); function.

It works like a charm in anywhere in my page before I call the function

<?php get_sidebar(); ?>

After that impossible to show the post thumbnail.
I’ve tried with

and also

but nothing happens.

Here is my whole code :

<?php
/**
 * The Template for displaying all single posts
 *
 * @package WordPress
 */
get_header(); ?>
<div id="pageHeader" >
  <div id="pageHeader-inner"> <span class="shadow"></span><img src="<?php bloginfo('template_url'); ?>/images/header_01.jpg" /></div>
</div>
<div class="container" id="pageTitle">
        <h1><?php the_title(); ?></h1>
</div>
<!--Begin of content-->
<div class="grey-bg">
  <div class="container">
  <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div class="row">
      <div class="col-sm-3 sidebar">
      <!-- Sub Nav  -->
            <?php if ( is_page() ) { ?>
            <?php
            if($post->post_parent)
            $children = wp_list_pages('title_li=&child_of='.$post->post_parent.'&echo=0'); else
            $children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0');
            if ($children) { ?> 
      <div class="sidebar-module sub-menu">
          <ul>
            <?php echo $children; ?>
          </ul>
       </div>
       <?php } } ?>
<!--Works perfectly till here -->
        <?php get_sidebar(); ?>
<!--Broken till here-->  
      </div>  <!-- /.sidebar --> 
      <div class="col-sm-9">
        <div class="content-main">
        <div class="content white-bg left-stroke <?php echo $post->post_name; ?>">
        <?php if ( has_post_thumbnail() ) the_post_thumbnail(); ?>  
            <?php the_content(); ?>
           <?php endwhile; ?>
            <?php else : ?>
            <div <?php post_class(); ?> id="post-<?php the_ID(); ?>">
                <h1><a href="<?php bloginfo('site_url'); ?>">Not Found</a></h1>
            </div>
            <?php endif; ?>
         </div> <!-- /.content --> 
        </div><!-- /.content-main --> 
      </div>
    </div>
    <!-- /.row -->     
  </div>
  <!-- /.container --> 
</div>
<?php get_footer(); ?>

Thank’s a lot for your responses.

Read more here: WordPress - Why calling the_post_thumbnail() AFTER get_sidebar() doesn’t show anything on my template


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , , , ,

Wordpress related questions and answers: