WordPress.org

Ready to get started?Download WordPress

Forums

Getting 1 Category of Posts on Index (7 posts)

  1. Randyd
    Member
    Posted 9 years ago #

    Everything was working.

    I was using

    <?php
    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.

    Thanks

  2. darrellberry
    Member
    Posted 9 years ago #

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

  3. Joshua Sigar
    Member
    Posted 9 years ago #

    The following alternative may work

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

  4. darrellberry
    Member
    Posted 9 years ago #

    this seems to work for me:

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

  5. Kafkaesqui

    Posted 9 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
    Member
    Posted 9 years ago #

    Thanks alphaoide,

    That worked.

    Randyd

  7. orangeguru
    Member
    Posted 9 years ago #

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

    http://www.orangeguru.biz/clients/rogler/

    <?php
    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:

    http://wordpress.org/support/topic.php?id=10759#post-81177

    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

Tags

No tags yet.