WordPress.org

Forums

Category View Problem: Display posts by Group, etc. (4 posts)

  1. depiction
    Member
    Posted 7 years ago #

    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; ?>

    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.)

  2. depiction
    Member
    Posted 7 years ago #

    No one has any ideas?

  3. depiction
    Member
    Posted 7 years ago #

    Anyone? I really need to get this solved soon!

  4. depiction
    Member
    Posted 7 years ago #

    Well I decided to try another way. It basically includes a template file based depending on which category. This code doesn't display anything. Why?

    <?php
    if (is_home())
    {
    	include (TEMPLATEPATH . "<?php echo get_settings('home'); ?>/wp-content/themes/simpla/postlisting_home.php");
    }
    else if (is_category('3')) {
        include (TEMPLATEPATH . "<?php echo get_settings('home'); ?>/wp-content/themes/simpla/postlisting_news.php");
    }
    else if (is_category('4')) {
        include (TEMPLATEPATH . "<?php echo get_settings('home'); ?>/wp-content/themes/simpla/postlisting_media.php");
    }
    else {
        include (TEMPLATEPATH . "<?php echo get_settings('home'); ?>/wp-content/themes/simpla/postlisting_misc.php");
    }
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic