Forums

[HELP] How to access posts individually from The Loop ?!? (2 posts)

  1. mattjakob
    Member
    Posted 3 years ago #

    Hello.
    Im writing a new template and I want to displace each post in a different position (total of 4 posts per page). To do so I created the various DIV containers and associated a class + ID to each of them (box1, box2, box3, etc.)

    How can I put each one post in each one container?
    post 1 -> box 1
    post 2 -> box 2
    etc.

    I'd also like to create an 'Older post' function where I shift the content of the boxes (content of box2 -> goes into box1 etc.)
    I think I will use Ajax + jQuery for this...

    Any ideas?

    THANKS

  2. stvwlf
    Member
    Posted 3 years ago #

    Hi

    read this http://codex.wordpress.org/Template_Tags/get_posts

    and this http://codex.wordpress.org/Template_Tags/query_posts

    Here is one way to do it:

    <?php $recent = new WP_Query("cat=1&showposts=1"); while($recent->have_posts()) : $recent->the_post();?>
    	<h2><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
    	<?php the_content(__('Read the story &raquo;'));?><div style="clear:both;"></div>
    <?php endwhile; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic