WordPress Category View Problem: Display posts by Group, etc.

Discussion in 'PHP' started by depiction, Mar 15, 2008.

  1. #1
    I already posted this on the WordPress forums, but never received any response for help. Since this is an issue involving some PHP code, I thought someone here might be able to help me solve my problem.

    ---------------------------

    I am trying to format the grouping of posts in the following manner.

    Category 1 Header Image

    Post 1 in Category 1
    Post 2 in Category 1
    ..etc.

    Category 2 Header Image

    Post 1 in Category 2
    Post 2 in Category 2
    ..etc.

    I have got it to display correctly when only on the homepage using the following code:

    
    <?php
       if (is_home()) {
          query_posts("showposts=5&cat=3");
       }
    ?>
    	<?php if (have_posts()) :?>
        <img src="/images/cat1_header.gif" alt="Title" title="Category 1 Title" /><br />
    		<?php $postCount=0; ?>
    		<?php while (have_posts()) : the_post();?>
    			<?php $postCount++;?>
    	<div class="entry entry-<?php echo $postCount ;?>" style="margin-bottom: -5px;">
    		<div class="entrytitle">
            <table cellpadding="0" cellspacing="0" border="0">
            	<tr>
                	<td width="64" valign="top"><h3><?php the_time('m.d.y') ?></h3></td>
    				<td valign="top"><h2><?php the_title(); ?></h2>
                    	<p class="entrypreview">
    					<?php the_content('Read the rest of this entry &raquo;'); ?>
    					</p></td>
                </tr>
            </table>
    		</div>
    	</div>
    	<?php endwhile; ?>
        <img src="/images/page_white_stack.png" alt="" /><a href="/cat1earchive.php">Category 1 Archive</a><br />
    		<div class="navigation">
    			<div class="alignleft"><?php next_posts_link('&laquo; Previous Entries') ?></div>
    			<div class="alignright"><?php previous_posts_link('Next Entries &raquo;') ?></div>
    		</div><br />
    
    	<?php else : ?>
    
    		<h2>Not Found</h2>
    		<div class="entrybody">Sorry, but you are looking for something that isn't here.</div><br />
    
    	<?php endif; ?><br />
    
    <?php
          query_posts("showposts=5&cat=4");
    ?>
    	<?php if (have_posts()) :?>
    <img src="/images/cat2_header.gif" alt="Title 2" title="Cat2" /><br />
    		<?php $postCount=0; ?>
    		<?php while (have_posts()) : the_post();?>
    			<?php $postCount++;?>
    	<div class="entry entry-<?php echo $postCount ;?>" style="margin-bottom: -5px;">
    		<div class="entrytitle">
            <table cellpadding="0" cellspacing="0" border="0">
            	<tr>
                	<td width="64" valign="top"><h3><?php the_time('m.d.y') ?></h3></td>
    				<td valign="top"><h2><?php the_title(); ?></h2>
                    	<p class="entrypreview">
    					<?php the_content('Read the rest of this entry &raquo;'); ?>
    					</p></td>
                </tr>
            </table>
    		</div>
    	</div>
    	<?php endwhile; ?>
        <img src="/images/page_white_stack.png" alt="" /><a href="/cat2archive.php">Category 2 Archive</a><br />
    		<div class="navigation">
    			<div class="alignleft"><?php next_posts_link('&laquo; Previous Entries') ?></div>
    			<div class="alignright"><?php previous_posts_link('Next Entries &raquo;') ?></div>
    		</div><br />
    
    	<?php else : ?>
    
    		<h2>Not Found</h2>
    		<div class="entrybody">Sorry, but you are looking for something that isn't here.</div><br />
    
    	<?php endif; ?>
    
    Code (markup):
    There are a few problems with it that I can't figure out.

    1. When viewing an individual post page, it always displays the category 1 header then the requested post regardless of category. Below that it displays the second category listing as done on the home page:

    Category 2 Header Image

    Post 1 in Category 2
    Post 2 in Category 2
    ..etc.

    It should instead only display the category header image for the relevant category and the individual post.

    2. If I click on my archive list to view all entries from a specific month, I see the exact same content as on the homepage. (It basically redirects you to the homepage regardless of archive month selected.)
     
    depiction, Mar 15, 2008 IP
  2. depiction

    depiction Active Member

    Messages:
    822
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    58
    #2
    Can anyone help me with this?
     
    depiction, Mar 17, 2008 IP