WordPress.org

Ready to get started?Download WordPress

Forums

posts over riding page content (2 posts)

  1. Jon Henwood
    Member
    Posted 4 years ago #

    Hi

    Have a problem with my site and I cant seem to find a solution. Basically I have two div's one has the code for a single post, code as follows

    <div id="latest_news">
    			<div id="post_content_box">
    			<!-- page content -->
    			<?php if (have_posts()) : ?>
    			<?php while (have_posts()) : the_post(); ?>
    			<!--<h1><?php the_title(); ?></h1>-->
    			<!--<?php the_content(); ?>-->
    			<?php endwhile; ?>
    			<?php else : ?>
    			<?php _e('Sorry, no posts matched your criteria.'); ?>
    			<?php include (TEMPLATEPATH . "/searchform.php"); ?>
    			<?php endif; ?>
    			<?php
    			$args = array(
     				'numberposts' => 1,
      				'cat' => 1
      				);
    			$posts=get_posts($args);
    			if ($posts) {
    			foreach($posts as $post) {
    			setup_postdata($post);
    			?>
    			<p><?php the_time('m.d.y') ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
    			<?php the_content(); ?>
    			<?php }
    			}
    			?>
    			</div>
    			</div>

    The other div concerned houses the page content or the list of posts, code as follows

    <div id="right_area">
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    <h1><?php the_title(); ?></h1>
    <div id="content_box">
    <?php the_content(); ?>
    <?php endwhile; ?>
    <?php else : ?>
    <?php _e('Sorry, no posts matched your criteria.'); ?>
    <?php include (TEMPLATEPATH . "/searchform.php"); ?>
    <?php endif; ?>
    		</div>
    	</div>

    The problem is that if I don't make use of the left div the content in the right div works fine. However if I do use the code in the left div the right div only displays the same post as in the left div.

    What I am trying to achieve is to have the latest post only to apear in the left div and the page content and (what I think is) the loop which displays "X" amount of posts.

    Please can some one help me asap.

    Thanks
    Jon

  2. esmi
    Forum Moderator
    Posted 4 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic