Title: Archive.php issue
Last modified: August 19, 2016

---

# Archive.php issue

 *  [michaelmcguk](https://wordpress.org/support/users/michaelmcguk/)
 * (@michaelmcguk)
 * [18 years ago](https://wordpress.org/support/topic/archivephp-issue/)
 * Hello,
 * Any help with this would be brilliant.
 * My current ‘News page’ is like: /index.php?cat=5 however, on this page(which 
   is styled by archive.php), I also want a bit underneath it to show all the posts
   that should be in /index.php?cat=12 , is this a possibility.
 * Can someone show me how?

Viewing 13 replies - 1 through 13 (of 13 total)

 *  [ivovic](https://wordpress.org/support/users/ivovic/)
 * (@ivovic)
 * [18 years ago](https://wordpress.org/support/topic/archivephp-issue/#post-761091)
 * seriously dude, get out of my time zone…
 *     ```
       <?php
       if (is_category(5)) :
           $readposts = get_posts('numberposts=5&category=12');
           foreach($readposts as $post) : setup_postdata($post);
           ?>
   
              [regular post stuff goes here]
   
           <?php
           endforeach;
       endif;
       ?>
       ```
   
 * This should work, barring any tyops.
 * (I was kidding about the time zone thing… mostly 😉 )
 *  Thread Starter [michaelmcguk](https://wordpress.org/support/users/michaelmcguk/)
 * (@michaelmcguk)
 * [18 years ago](https://wordpress.org/support/topic/archivephp-issue/#post-761098)
 * Hahahah, don’t worry, that is the last question. I’m going to become an Insomniac
   to keep out the time zone thang 😀
 * Thank you
 *  [ivovic](https://wordpress.org/support/users/ivovic/)
 * (@ivovic)
 * [18 years ago](https://wordpress.org/support/topic/archivephp-issue/#post-761099)
 * haha, you’re welcome… don’t worry, I’m kidding, I wouldn’t be here if I didn’t
   get some perverse joy out of other people’s suffering.
 * I mean… I like helping people.
 *  Thread Starter [michaelmcguk](https://wordpress.org/support/users/michaelmcguk/)
 * (@michaelmcguk)
 * [18 years ago](https://wordpress.org/support/topic/archivephp-issue/#post-761103)
 * Haha, can’t help but get a kick out of the old suffering game 🙂
 * I seem to be getting a Parse Error on the ‘endforeach’ part:
 * `Parse error: syntax error, unexpected T_ENDFOREACH`
 * My code:
 *     ```
       <?php
       		if (is_category(5)) :
           			$readposts = get_posts('numberposts=5&category=12');
           			foreach($readposts as $post) : setup_postdata($post);
           		?>
              			<?php while (have_posts()) : the_post(); ?>
       		<div class="post">
       				<h3 id="post-<?php the_ID(); ?>"><?php the_title(); ?></h3>
       				<small><?php the_time('l, F jS, Y') ?></small>
   
       				<div class="entry2" style="margin-right:135px;position:relative;">
   
       				<?php the_content() ?>
       				</div>
   
       		</div> <!-- end of post class element -->
   
           		<?php
           		endforeach;
       		endif;
       		?>
       ```
   
 * Promise this is the last time I ask 🙂
 *  [ivovic](https://wordpress.org/support/users/ivovic/)
 * (@ivovic)
 * [18 years ago](https://wordpress.org/support/topic/archivephp-issue/#post-761104)
 * ah, its because you’re putting the while loop and stuff in there as well…
 * I mean lets get that right first, then we’ll know for sure.
 * put only this part into my code above:
 *     ```
       <div class="post">
          <h3 id="post-<?php the_ID(); ?>"><?php the_title(); ?></h3>
          <small><?php the_time('l, F jS, Y') ?></small>
          <div class="entry2" style="margin-right:135px;position:relative;">
             <?php the_content() ?>
          </div>
       </div>
       ```
   
 * I’ve left out the parts you have got commented there, since they wouldn’t be 
   showing up anyway.
 *  Thread Starter [michaelmcguk](https://wordpress.org/support/users/michaelmcguk/)
 * (@michaelmcguk)
 * [18 years ago](https://wordpress.org/support/topic/archivephp-issue/#post-761105)
 * Brilliante, worked a dream 😀
 * Thanks
 *  [ivovic](https://wordpress.org/support/users/ivovic/)
 * (@ivovic)
 * [18 years ago](https://wordpress.org/support/topic/archivephp-issue/#post-761106)
 * anytime… 🙂
 * remember to vary the numposts= part, or remove it if you want them all.
 *  Thread Starter [michaelmcguk](https://wordpress.org/support/users/michaelmcguk/)
 * (@michaelmcguk)
 * [18 years ago](https://wordpress.org/support/topic/archivephp-issue/#post-761108)
 * Aaaah good call. I’ll probably want to list them all, so may remove that clause.
 * Thank you.
 *  Thread Starter [michaelmcguk](https://wordpress.org/support/users/michaelmcguk/)
 * (@michaelmcguk)
 * [18 years ago](https://wordpress.org/support/topic/archivephp-issue/#post-761110)
 * Is there an is_not_category?
 * I’ve been trying things like:
 * if (!in_category(’26’) && !in_category(‘3’) )
 * if (!is_category(’26’) && !is_category(‘3’) )
 * but getting nowhere 🙁
 * Have you experienced this before?
 *  [ivovic](https://wordpress.org/support/users/ivovic/)
 * (@ivovic)
 * [18 years ago](https://wordpress.org/support/topic/archivephp-issue/#post-761112)
 * the !is_category should work.. but.. your conditional is kind of odd because 
   no one thing can be both category 26 AND category 3 at the same time.
 * maybe you want || which is a logical OR…
 * that way either 26 or 3 are covered.
 * this assumes you’re actually doing this on a category page as per this thread,
   and not in a single post or something.
 *  Thread Starter [michaelmcguk](https://wordpress.org/support/users/michaelmcguk/)
 * (@michaelmcguk)
 * [18 years ago](https://wordpress.org/support/topic/archivephp-issue/#post-761114)
 * Yes, sorry it should be the || I’m using.
 * Thank you.
 *  [ivovic](https://wordpress.org/support/users/ivovic/)
 * (@ivovic)
 * [18 years ago](https://wordpress.org/support/topic/archivephp-issue/#post-761115)
 * I get those screwed up all the time. If you could see my FTP logs you’d find 
   the same file uploaded 16 times in the same 5 minutes, as I discover yet more
   brain farts.
 *  Thread Starter [michaelmcguk](https://wordpress.org/support/users/michaelmcguk/)
 * (@michaelmcguk)
 * [18 years ago](https://wordpress.org/support/topic/archivephp-issue/#post-761117)
 * hahaha tell me about it, try 200 in an hour 😀

Viewing 13 replies - 1 through 13 (of 13 total)

The topic ‘Archive.php issue’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 13 replies
 * 2 participants
 * Last reply from: [michaelmcguk](https://wordpress.org/support/users/michaelmcguk/)
 * Last activity: [18 years ago](https://wordpress.org/support/topic/archivephp-issue/#post-761117)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
