WordPress.org

Ready to get started?Download WordPress

Forums

One Category as Index? (6 posts)

  1. Gdo33
    Member
    Posted 8 years ago #

    I am hoping that some one can help me with might be a simple solution. For a site that has say 10 categories yet one is the main subject, how can i set index.php/my home page....to show posts only from that one category?

    I know a simple re-direct can work normally but I am completely new to the wordpress enironment and i am thinking there mey be more to it.

    I am a sports blog but do write about music and other things here and there. I would prefer that those posts show on their category pages and have only sports posts shows on my home page.

    Thanks in advance for any replies.

    Gdo33

  2. monkeypup
    Member
    Posted 8 years ago #

    Easy peasy, man. Go get the plugin called opt-in front page from Semiologic.com. Then, you can decide what posts go to the front page by assigning them a category you decide (the default category for the plugin is blog).

  3. ZAGG
    Member
    Posted 8 years ago #

    Thanks monkeypup I was looking for something like this. But when the plug-in hides also the sidebar when I go to the other categories. Do you know how to fix it?

  4. monkeypup
    Member
    Posted 8 years ago #

    Not sure, Zagg. I'd suggest you contact Denis (the plugin's designer). He's a great guy (who makes amazing plugins and a great theme) and can probably point you in the right direction.

  5. evL
    Member
    Posted 8 years ago #

    Well this worked for me. It is suggested right from the codex site.
    The URL is ::
    http://codex.wordpress.org/FAQ_Layout_and_Design#How_do_I_hide_a_category_from_the_front_page_index.php.3F

    So basically enable my-hacks.php support in:
    Options / Miscellaneous / Use legacy my-hacks.php file support.

    Then make or edit your my-hacks.php file which needs to be in the wordpress root and add this line:
    if ((empty($_GET['cat']))&&(!preg_match('/wp-admin/', $_SERVER['REQUEST_URI']))) $cat = '-1';
    //Replace 1 with your category

    What I wanted was only one category to show on the front page so I have this line repeated about six times and replaced the "1" above with the nubers 2 thru 7 in each instance of the line. This keeps categories 2 thru 7 off the front page.

    -

  6. Jaycos
    Member
    Posted 8 years ago #

    forget about all plugins and simply enter this into your index.php or home.php somewhere before the loop starts:

    <?php query_posts('cat=3'); ?>

    This is to display posts from category-ID 3 only. For more parameters see
    http://codex.wordpress.org/Template_Tags/query_posts#Category_Parameters

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags