• Is there a way to show only a specific category by default? When a user first enters the page I only want to display the “news” category.
    Thanks,
    Andrew

Viewing 5 replies - 1 through 5 (of 5 total)
  • Yes.
    In your index.php you want to add this code:

    <?php
    /* Don't remove this line. */
    // Here is where you specify the category of your new page, my example is "11" but it can be any cat or "p"ost you choose.
    $cat="11";
    // here's where you inform this new index where the admin stuff is the ../ says go back a folder
    require('../wp-blog-header.php');
    ?>

    happy to provide an effective answer in the face of feeling quite stupid lately…
    dss

    I added that code,
    but now it wont let me switch to the other categories

    Had the same problem. I added the following in wp-blog-header.php at ca. line 70 (before the comment line // Sending HTTP headers)
    if (empty($cat)) {
    $cat = '1';
    }

    Works for me, hasn’t broken anything yet.

    miik,
    in my case posting the default category to the wp-blog-header.php file works fine when viewing the site but breaks the admin section.
    if I add the code
    if (empty($cat)) {
    $cat = ‘1’;
    }
    and open the Edit page in Admin, only posts belonging to category with ID = 1 appear on the page.
    any solution to this?
    Thanks!

    My solution is a workround i.e. just enter an “a” in the “Show Posts That Contain…” box. All the posts then show up for editing.
    Not ideal but seems to work….
    David

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘start with default category’ is closed to new replies.