[resolved] Problem with template not showing correct page content (7 posts)

  1. richF
    Posted 3 years ago #

    Hi all,

    I'm still getting to grips with coding for WordPress and having a bit of a weird issue. I've created by own template to appear on the homepage of my website.

    As part of it, I've created a couple of new widget areas (which work fine). But in one of the areas I've put in the category posts widget - which returns a list of posts recently added to a defined category.

    This works, but once it's finished it appears to have overwritten what was in the the_content() loop data and shows content from the last post pulled out of the category posts widget and displays that as the content to the page instead of the actual content.

    I've moved the loop to no avail - any help greatly appreciated!

    My template:

    if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
    				<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    					<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar("image-banner-widget-area") ) : ?>
    					<?php endif; ?>
    					<div class="clr"></div>
    					<div id="homepage-container">
    <!-- This is where the category posts widget is shown on the page -->
    						<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar("lhs-widget-area") ) : ?><?php endif; ?>
    						<div class="entry-content">
    <!-- The content of the page should appear here - but get the content from a post instead -->
    							<?php the_content(); ?>
    						</div><!-- .entry-content -->
    						<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar("rhs-widget-area") ) : ?><?php endif; ?>
    						<div class="clr"></div>
    				</div><!-- #post-## -->
    				<?php comments_template( '', true ); ?>
    <?php endwhile; // end of the loop. ?>
  2. Michael
    Forum Moderator
    Posted 3 years ago #

    can you post the download link for that category posts widget plugin?

    as a temporary fix, possibly try to add <?php wp_reset_postdata(); ?> after each dynamic sidebar section (untested).

  3. richF
    Posted 3 years ago #


    Thanks for the reply, I tried your coding suggestion but to no effect.

    The plugin can be found here: http://wordpress.org/extend/plugins/category-posts/

  4. Michael
    Forum Moderator
    Posted 3 years ago #

    try to edit the plugin file - cat-posts.php -
    and after these lines:

    <?php if ( $instance['comment_num'] ) : ?>
    			<p class="comment-num">(<?php comments_number(); ?>)</p>
    			<?php endif; ?>

    add: wp_reset_postdata();

  5. richF
    Posted 3 years ago #

    Thanks alchymyth, I've tried it, but doesn't change anything unfortunately.

  6. richF
    Posted 3 years ago #


    Any chance of some help on this one? I'm still struggling to get this working.


  7. richF
    Posted 3 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic