WordPress.org

Ready to get started?Download WordPress

Forums

Make Homepage display only posts from a single category (7 posts)

  1. 9tailedfox0531
    Member
    Posted 1 year ago #

    this is my code, please help my website is http://www.pimpanime.com and i need all the recent posts to disappear looks really tacky like that i just want the 1 post at the top and only 1 category to appear on front page like site-news or updates and information ect.

    <?php get_header(); ?>
    
    <div id="content">
    <?php include (TEMPLATEPATH . '/slide.php'); ?>	
    
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    
    <div class="box <?php if (++$counter % 2 == 0) { echo "last"; }?>" id="post-<?php the_ID(); ?>" id="post-<?php the_ID(); ?>">
    
    <div class="boxtitle">
    		<h2><a>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    <div class="data">
    	<span class="clock"> On <?php the_time('F - j - Y'); ?></span>
     		<span class="comm"><?php comments_popup_link('0 Comment', '1 Comment', '% Comments'); ?></span>
    </div>	
    
    </div>
    
    <div class="cover">
    	<div class="entry">
    	<?php cldb_home_image();?>
    		<?php the_excerpt(); ?>
    <div class="clear"></div>
    	</div>
    </div>
    
    </div>
    
    <?php endwhile; ?>
    
    <div class="clear"></div>
    
    <div id="navigation">
    <?php if(function_exists('wp_pagenavi')) : ?>
    <?php wp_pagenavi() ?>
    <?php else : ?>
            <div class="alignleft"><?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?></div>
            <div class="clear"></div>
    <?php endif; ?>
    
    </div>
    
    <?php else : ?>
    		<h1 class="title">Not Found</h1>
    		<p>Sorry, but you are looking for something that isn't here.</p>
    <?php endif; ?>
    
    </div>
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>

    [Moderator Note: Please post code or markup snippets between backticks or use the code button. Or better still - use the pastebin. As it stands, your code may now have been permanently damaged/corrupted by the forum's parser.]

  2. radhika
    Member
    Posted 1 year ago #

    @9tailedfox0531
    you can be used this code to display a single post & category in your template.

    display a single post:

    <?php
             $abc = query_posts(array('posts_per_page' => 1,'paged' => get_query_var('paged')) );
    
    ?>

    and display a single category (include the category id in this code):

    <?php wp_list_categories('include=3&title_li='); ?>

    you can follow this link.

  3. 9tailedfox0531
    Member
    Posted 1 year ago #

    where in my code would i post this what should my index look like

  4. radhika
    Member
    Posted 1 year ago #

    you want to display a particular category post on your site.

  5. 9tailedfox0531
    Member
    Posted 1 year ago #

    i just want the feed of 1 category to go on home page, all other categories excperted

  6. radhika
    Member
    Posted 1 year ago #

    You have to add this code after this <div id="content"> in your code.:

    <?php
        $a = query_posts(array(
                                     'cat' => 3,  //edit here the category id
                                     'posts_per_page' => 1,
                                     'paged' => get_query_var('paged'))
                             );
    ?>
  7. 9tailedfox0531
    Member
    Posted 1 year ago #

    Thank you that worked perfectly Please close topic.

Topic Closed

This topic has been closed to new replies.

About this Topic