• I am unhappy with the default $posts array when no category is defined, so I would like to force the category when a user is running index.php for the first time (with no ‘cat=x’ parameter). This seems simple enough at first glance, just insert an <pre> if isset($_GET[‘cat’]) </pre> to check to see whether the category has been defined and if it hasn’t force it to the one I want.
    But I can find no mention of $_GET in index.php. How does index.php know what category to use? How can I force the default to be something specific?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The wiki should help:
    http://wiki.wordpress.org/index.php/show-one-category-on-front-page
    That code foces a specific category when viewing the index of the site. As far as your code goes, a simple “if (isset($cat))” is all you need. The $_GET is implied.

    Thread Starter redneck

    (@redneck)

    Thanks for that.
    For some reason, the code in the Wiki didn’t work. I don’t know why, since I don’t really understand what it is doing:
    <?php
    if ('/' == $_SERVER['REQUEST_URI'])
    $cat = 1;
    ?>

    That didn’t seem to have any effect. So I went with my initial instinct:
    <?php
    if (!isset($cat))
    $cat = 1;
    ?>

    This works just fine.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Forcing the category with index.php’ is closed to new replies.