• 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.

Viewing 7 replies - 1 through 7 (of 7 total)
  • 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.

    Thread Starter mccammog

    (@mccammog)

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

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

    becuase if i go to:

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

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

    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?

    Thread Starter mccammog

    (@mccammog)

    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: https://g1c9.com/?cat=1&#8221;);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..?

    Thread Starter mccammog

    (@mccammog)

    Anyone got any ideas…?

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

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

    Thread Starter mccammog

    (@mccammog)

    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.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Only showing 1 categories posts on index?’ is closed to new replies.