Treehouse: Grow your CSS skills. Land your dream job.

wordpress archive help!

  • # January 28, 2009 at 11:29 pm

    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

    # January 29, 2009 at 8:27 am

    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.

    # January 29, 2009 at 5:51 pm

    This tag should list all pages in a certain category.

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

    This tag needs to be in the loop

    Read this for more info:

    # January 29, 2009 at 10:09 pm

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

    < ?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()) { ?>

    Category: < ?php echo single_cat_title(); ?>

    < ?php } ?>

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

    Monthly Archives

      < ?php wp_get_archives('type=monthly'); ?>

    Category Archives

      < ?php wp_list_categories('title_li='); ?>

    Post-by-Post Archives

      < ?php wp_get_archives('type=postbypost'); ?>

    < ?php endwhile; endif; ?>

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

    < ?php get_footer(); ?>

    # March 30, 2011 at 11:33 am

    Hey Dave, 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.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.