treehouse : what would you like to learn today?
Web Design Web Development iOS Development

wordpress archive help!

  • hello
    is anyone familar with any php function that i could use within my archive page, so that it will only show
    post for a certain category.
    basicly i have post coming from my home page, and also from a seperate news page.
    currently im creating an archive for my news page, but i dont want it to show the entries fro my home.
    ive search the web for hours but have not found anything.

    thanks in advance
  • its me again, perhaps im not wording my question in the correct way. is anyone familar with how one would go about setting up unique archive pages for seperate categegories, or seperate pages. ultimately this is what im trying to do. im certain that if i can be pointed in that direction, this would also give me the answer for how to not show postings from another page/category within an archive page.
  • This tag should list all pages in a certain category.

    	<?php query_posts('cat=0');     ?>


    This tag needs to be in the loop
    http://codex.wordpress.org/The_Loop

    Read this for more info:
    http://codex.wordpress.org/Template_Tags/query_posts
  • hello and thanks for replying. actually i tried to use the querypost function but this does not work. the following is my code for my archive page. when i insert the querypost function within the loop, my post acts strange and insert a long list of repeating the post.
    again this is the code that im using, but the issue is that my archive page is displaying post from all post (particularly home page) i want it to display only the post from cat=5. im mainly refering to the postbypost section, the month section and category section will be removed.

    <?php
    /*
    Template Name: Archive Page
    */
    ?>

    <?php get_header(); ?>


    <div id=\"newspage\">

    <div id=\"page\">

    <div id=\"contentleft\">

    <div id=\"newscontent\">

    <?php if (have_posts()) : ?>
    <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>

    <?php /* If this is a category archive */ if (is_category()) { ?>
    <h2 class=\"sectionhead\">Category: <?php echo single_cat_title(); ?></h2>






    <?php } ?>



    <?php query_posts('cat=5'); ?>
    <?php while (have_posts('cat=5')) : the_post(); ?>

    <h2 class=\"sectionhead\">Monthly Archives</h2>
    <div class=\"post\">
    <ul id=\"archives\"><?php wp_get_archives('type=monthly'); ?></ul>
    </div>

    <h2 class=\"sectionhead\">Category Archives</h2>
    <div class=\"post\">
    <ul id=\"archives\"><?php wp_list_categories('title_li='); ?></ul>
    </div>

    <h2 class=\"sectionhead\">Post-by-Post Archives</h2>
    <div class=\"post\">
    <ul id=\"archives\"><?php wp_get_archives('type=postbypost'); ?></ul>
    </div>

    <?php endwhile; endif; ?>

    <div class=\"navigation\">
    <div class=\"alignleft\">
    <?php posts_nav_link('','','&laquo; Previous Entries') ?>
    </div>
    <div class=\"alignright\">
    <?php posts_nav_link('','Next Entries &raquo;','') ?>
    </div>
    <div style=\"clear:both;\"></div>
    </div>

    </div>



    </div>

    <?php include (TEMPLATEPATH . \"/newsbar.php\"); ?>

    </div>




    <?php get_footer(); ?>

    </div>
  • Hey Dave,

    http://wordpress.org/extend/plugins/wp-category-archive/ is the plugin you are looking for. I'm also in search for similar solution, but without plugin.

    Ofcourse, using querypost inside archive page won't work.

    PS : There are some permalink hacks to take care of to make it work, do read the FAQ page.