Getting 1 Category of Posts on Index (7 posts)

  1. Randyd
    Posted 11 years ago #

    Everything was working.

    I was using

    if (empty($cat)) {
    $cat = '1';

    on the top of my index page. Only those posts from category 1 are showing up. But when I click on other categories, the posts from category 1 are showing up on other pages -example: in category 2.

    If anyone knows what happened or can give me some direction, it would be appreciated.


  2. darrellberry
    Posted 11 years ago #

    did you ever find an answer to this? i have the same need...?

  3. Joshua Sigar
    Posted 11 years ago #

    The following alternative may work

    if ( empty( $_SERVER['QUERY_STRING'] ) ) {
    $cat = "1";

  4. darrellberry
    Posted 11 years ago #

    this seems to work for me:

    <?php if (empty($_GET['cat'])) $cat="1"; ?>

  5. Kafkaesqui

    Posted 11 years ago #

    darrellberry, that works if one doesn't link to archives, or authors' posts, or anything other than category pages. The one alphaoide points out makes sure no query-string exists, the case for the home page (under most circumstances).

  6. Randyd
    Posted 11 years ago #

    Thanks alphaoide,

    That worked.


  7. orangeguru
    Posted 10 years ago #

    Oke, this is not working on my current testblog (wp1.5):


    if (empty($_SERVER['QUERY_STRING'] ) ) {
    $cat = "2";

    <?php include "header.php"; ?>

    It still shows ALL categories.

    I tried to find Kittens 'show-categories' plugin - but her site is down at the moment and the plugin directory doesn't show anything either.

    I also tried the mini plugin from here:


    But it tricks WP into showing the ARCHIVE page of one category - instead if the index page. Since I have conditions in my theme either for index or archive this is not helpful either.

    Any insights greatly appreciated. Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.