Support » Fixing WordPress » Only display posts from defined category.

  • Hi

    What I am trying to do is create a page what only displays posts which are in a specified catagory i.e. a post that falls under the catagory “Photoshop” will be displayed on my predefined Photoshop page.

    Hackzle.info

    I hope I have made this as clear as possible as I am confused at where to even begin. Is there a plugin which will make this possible or something within wordpress that I am missing.

    I am grateful for any help I recieve.
    Thanks
    Andrew

Viewing 4 replies - 1 through 4 (of 4 total)
  • Well the WordPress native archive ability will handle this automatically.

    Create the category. Assign it to a post. Switch to the WordPress Default theme and see how it use the wp_list_categories to present a link to that category’s posts.

    Also look at the Page of Posts example in the Pages article.

    Thank you very much for such a quick response, although this has not solved my problem. I found an plugin Catagory Page configured the settings, but still to no success so I decided to see if it was my theme, I changed to the default WordPress template and it worked.

    I was curious (as I am a not experienced in PHP and WordPress) if it would help if i provided the code for my page.php and my archive.php that you may be able to help me. My theme is the BlackPower theme.

    Page.php

    <?php get_header(); ?>
    
    	<div id="content" class="narrowcolumn">
    
    		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    		<div class="post-page" id="post-<?php the_ID(); ?>">
    		<h2 class="page_title"><?php the_title(); ?></h2>
    			<div class="entry entry_page">
    				<?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>
    
    				<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
    
    				<?php edit_post_link('Edit this entry.', '<br /><p>', '</p>'); ?>
    			</div>
    		</div>
    		<?php endwhile; endif; ?>
    	</div>
    
    <?php get_footer(); ?>

    Archive.php

    <?php get_header(); ?>
    
    	<div id="content" class="narrowcolumn">
    
    		<?php if (have_posts()) : ?>
    
    		<?php $i=0; while (have_posts()) : the_post(); $i++; ?>
    
    			<div class="post" id="post-<?php the_ID(); ?>">
                    <div class="post-top">
                        <div class="post-title">
    
                            <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to 
    
    <?php if ( function_exists('the_title_attribute')) the_title_attribute(); else the_title(); ?>"><?php the_title(); ?></a></h2>
    						<h3>
    							Posted by <span><?php the_author() ?></span>  |  Posted in <span><?php the_category(', ') ?></span>  |  Posted on <?php the_time('d-m-Y') ?>
    						</h3>
                        </div>
    					<h4><?php comments_number('0', '1', '%'); ?></h4>
                    </div>
    
    				<div class="entry">
    					<?php if($i==1 || $i==2) : ?>
    						<?php theme_google_468_ads_show(); ?>
    					<? endif; ?>
    					<?php the_content('',FALSE,''); ?>
    				</div>
    
                    <div class="postmetadata">
    					<p><a href="<?php the_permalink() ?>">Continue Reading</a></p>
                    </div>
    			</div>
    
    		<?php endwhile; ?>
    
    		<div class="entry">
    			<?php theme_google_468_ads_show(); ?>
    		</div>
    
    		<div class="navigation">
    			<?php if(!function_exists('wp_pagenavi')) : ?>
                <div class="alignleft"><?php next_posts_link('Previous') ?></div>
                <div class="alignright"><?php previous_posts_link('Next') ?></div>
                <?php else : wp_pagenavi(); endif; ?>
    		</div>
    
    	<?php else : ?>
    
    		<h2 class="center">Not Found</h2>
    		<?php include (TEMPLATEPATH . '/searchform.php'); ?>
    
    	<?php endif; ?>
    
    	</div>
    
    <?php get_footer(); ?>

    Any help is greatly appreciated.
    Thanks
    Andrew

    I’m surprised that plugin works for you because it just allows you to assign a category to a particular page.

    But, with that said, please describe what is NOT working.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Only display posts from defined category.’ is closed to new replies.