WORDPRESS - Multiple Loops Only Going to One Post?


Posted on 16th Feb 2014 07:03 pm by admin

I have various pages with multiple loops and i need them to be individual to all other categories.

2 columns.

Left column shows 4 posts from category news just with the date and some custom information.

Right column, on the home page shows the latest post and every other page shows the post content from the one you have just clicked on in the left column, all the full post content appears there, with the left column still showing the latest posts still.

These two elements need to ignore all other categories and posts.

I have been using this multiple loop code, on both the news page and single page.
Code: [Select]<?php
/**
* @package WordPress
* @subpackage Starkers
*/

get_header();
?>


<?php get_sidebar(); ?>

<div id="grid_2">

<div id="news_links">
<ul>

// Get the last 3 posts in the featured category.

<?php query_posts('category_name=news&showposts=4'); ?>

<?php while (have_posts()) : the_post(); $data = get_post_meta( $post->ID, 'key', true );?>



<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
<span>
<li><?php the_time('F jS, Y') ?></li>
<li><?php the_title(); ?></li>
<li><?php echo $data[ 'place' ]; ?></li>
<li><?php echo $data[ 'location' ]; ?></li>
</span>
</a>
<?php endwhile ?>
</ul>
</div>
<!--news_links-->

<div class="clearFix"><!--x--></div>
</div>
<!--grid_2-->

//We reset the loop
<?php rewind_posts(); ?>




<div id="grid_3">

<?php if (have_posts()) : ?>

<?php query_posts('category_name=news&showposts=1'); ?>

<?php while (have_posts()) : the_post(); ?>



<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
<h2><?php the_title(); ?></h2>
<?php the_content('Read the rest of this entry &raquo;'); ?>
<p><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments &#38;#187;', '1 Comment &#38;#187;', '% Comments &#38;#187;'); ?></p>
</div>



<?php endwhile; ?>

<?php next_posts_link('&laquo; Older Entries') ?> | <?php previous_posts_link('Newer Entries &raquo;') ?>

<?php else : ?>

<h2>Not Found</h2>
<p>Sorry, but you are looking for something that isn't here.</p>
<?php get_search_form(); ?>

<?php endif; ?>

<div class="clearFix"><!--x--></div>
</div>
<!--grid_3-->

The problem i have is that regardless of which post you click on in the left column it always shows the same post in the right column, the most recent one, not the one you have just clicked on!

I think its something to do with this..
Code: [Select]<?php query_posts('category_name=news&showposts=1'); ?>
As its been told to show 1 post and its showing the most recent one.

Any idea how i can get it to show just the post you have clicked on in the right column?

No comments posted yet

Your Answer:

Login to answer
325 Like 22 Dislike
Previous forums Next forums
Other forums

Problem with PHP code- simple contact form
I'm relativily new to PHP; I know HTML and CSS stuff but I have a problem- I have a contact form wit

TimeStamp Column Problem...
I'm mad at my self and thinking I'm a little retarded. It just be some one mistake I'm missing here.

Run function every 5 mins ??
I have a function PostMessage()

How can I run it every 5 mins ??

Baffled by Undefined Index in Simple Array: Please Help!
Hello. I have a form which posts an array to this script. However, I can't seem to access the values

Help with Password Encoding/Decoding?
Trying to design a "change password" tool. On my signup code I'm using base64_encode, now

cURL error
So here is my code... I got it off of here... http://www.youtube.com/watch?v=XcgQUsorF_8
Because

Automatic Webpage ??
I have a page www.mysite.com/test.php with a
<form>
<textarea name=&q

Array to string conversion
Can anyone help me with this?

Notice: Array to string conversion in /home/..../index.php on l

get url?
how do i get the url of the page i'm currently on, on my website.. i think its get header.. how do i

Help with usergroups? prolly really quick
So were coding our own forums for a game system we made an we have the users level setup but now I n

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash