WordPress.org

Ready to get started?Download WordPress

Forums

Only showing 1 categories posts on index? (8 posts)

  1. mccammog
    Member
    Posted 8 years ago #

    Hey, how do I only show one categories posts on the index?

    I tried .htaccess but it didn't work for me, and I couldn't figure out how to use php header("location:") to forward to index.php?cat=1!

    How should I go about this?

    Thanks in advance, Cameron.

  2. MichaelH
    Member
    Posted 8 years ago #

    The_Loop#Exclude_Posts_From_Some_Category explains excluding all but one Category so you could use that thinkg to just include posts from one Category.

  3. mccammog
    Member
    Posted 8 years ago #

    Thanks for the response, but how would I go about implementing this to ONLY the root index?

    example: http://www.mysitehere.com/blog/

    becuase if i go to:

    http://www.mysitehere.com/blog/?cat=3

    I still want to see posts from category three, I only want this to apply to the index. :-/

  4. lisavollrath
    Member
    Posted 8 years ago #

    I do this on my site. I created a home.php file that only pulls posts from one category.

    The down side: I'm having trouble with my RSS only pulling updates to that one category. I'm working on a new home.php that will add links to the five or six most recently added or updated posts in every category, excluding the one I use for my main page.

    Clear as mud?

  5. mccammog
    Member
    Posted 8 years ago #

    clear as mud is a good way to put it.

    I didn't like your idea, so I tried putting the following my header.php file:

    <?
    $cat = $HTTP_GET_VARS['cat'];
    $p = $HTTP_GET_VARS['p'];
    if (($cat==null)&&($p==null)) { header("location: http://g1c9.com/?cat=1");exit; }
    ?>

    but now I'm getting a 403 forbidden error, and without the exit; i get a "Redirection will never complete" error..

    Why isn't this working..?

  6. mccammog
    Member
    Posted 8 years ago #

    Anyone got any ideas...?

  7. MichaelH
    Member
    Posted 8 years ago #

    Is this code example, derived from The_Loop#Exclude_Posts_From_Some_Category, useful?

    <?php if ( (in_category('3') && is_home()) ) { ?>

  8. mccammog
    Member
    Posted 8 years ago #

    With a little bit of toying, I got it to work.

    Thanks a lot guys, especcially you michael.

    PS: I ended up making a function for the whole post loop and then calling it at two different times with different arguments depending on weather its the home page or not.

Topic Closed

This topic has been closed to new replies.

About this Topic