Support » Plugins » Disabling a post from the “main” page

  • I’ll try to describe what I want to do, and hopefully someone can point me in the right direction:
    I want to have an “About” page for my blog, that will be linked to from the main site navigation (hard-coded.) I created a post, with comments turned off, that is to serve as the page itself. I then linked directly to that post (index.php?p=6&more=1&c=1). However, I don’t want that particular post to show up on my main index page with all the other “regular” posts. Is there a way I can keep that About page/post from showing up amongst my other recent posts?

Viewing 11 replies - 1 through 11 (of 11 total)
  • I think you could probably set it up as its own category, then filter that category out from the main list. There are at least one or two tricks to getting this working, that I think have been covered in numerous other articles around category filtering.




    Or, you could edit the post, and change it’s publish date to some time in the past…. I mean Waaaaaaaaaaaaaaaay in the past. I’ve done this a few times, to force things off the main page….

    Thanks for the tip. Now that you mention it, that makes perfect sense. I was banging my head trying to figure out how to filter a *post*, when filtering a category is simple enough. Some times things are so easy they’re impossible to see…

    That might also work.
    I’ve pretty much got David’s idea working, with one exception: the category I created (“About”) is showing up in my list of categories on the right (list_cats). Is there an easy way to keep it from showing up there? It’s off the homepage, thanks to
    if ($cat == ”)
    $cat = -14;
    but it still shows up in the categories…
    If not, I guess I can try TG’s idea.

    You could simply link to that exact post rather than creating a category for it.

    It’s worth remembering that, as you have your own server space, not all your text needs to be entered via WordPress. You can upload separate html pages, or text files that you can call using a standard php include. For example, I have files called,,, etc., which I can either make a separate page for or even incorporate into the sidebar: <?php include (‘’); ?> It just seems to be a much simpler and more flexible way of doing it.

    The more I think about this, the more sense this makes to be something more of a core feature (i.e., php modification) rather than trying to hack around some of the filtering…
    I’m thinking about maybe a special category number (like 0) or maybe a special category naming (how about prefixing a period like ‘hidden’ unix files?)… the second sounds better/easier. Those categories would be filtered out (maybe optionally, via a param) from the category lists. Then you’d make explicit buttons to get to the special content, either a by-name reference on a post, or a post number (since you’d know that), or by category id. I’d go for the post number/ID myself. 😉
    The other advantages of keeping it a category:
    – you could have multiple posts/pieces-of-content for special pages.
    – the content for your special pages is embedded in WP, and you don’t need an html editor or ftp access — you can change it whereever/whenever.
    However, I would agree that IF you want a lot of customizability to your special pages, then you SHOULD just make them independent php/html files to begin with. It’s so easy to make another php page, even based off the index.php to keep the major layout/flow, if you want complete control.
    But, say they are pages that you want to be able to add to on the fly, on the road, whatever, that’d lean toward the category/post approach working better for you. Oh, one other advantage/reason is if you really want the majority of your content stored/embedded in the database rather than in successive html/php files — for whatever reason. 😉

    I think we’re on the same page on this one…Since my “About” page is really just a post about the site, how I built it, and a blurb about me, making it a separate page (outside the WP system) didn’t make sense. I do want the ability to add to the page, as I add or remove core functionality from the site, or I want to update my own profile. Plus, I don’t want to have to modify two separate pages every time I make a change to the template.
    For now I’m going to live with the “About” category showing up in the category list, but when I have time I may figure out a way to keep it from showing up.

    Almost there!
    It was quite simple to filter out unwanted categories from the category list (see below.) I still have other issues though, related to this mess of “static” pages that are more site pages instead of posts, but need to use the same master template. Anyway, here’s what I did do keep my “About” category from showing up in the category list:
    In b2template-functions.php, I made the following changes:
    In the line:
    function list_cats($optionall = 1, $all = ‘All’, $sort_column = ‘ID’, $sort_order = ‘asc’, $file = ‘blah’, $list = true, $optiondates = 0, $optioncount = 0, $hide_empty = 1) {
    I added:
    , $filter = 0
    just after the $hide_empty = 1
    In-between the two lines:
    $query .= ” WHERE cat_ID > 0 “;
    $query .= ” GROUP BY post_category “;
    I inserted the line:
    $query .= ” AND cat_ID NOT IN ($filter) “;
    Next, in my index.php template, where I’m calling my category list, I changed it to:
    <?php list_cats(0, ‘All’, ‘name’, ‘asc’, ‘index.php’,true,0,1,1,’14,17′); ?>
    The bit at the end ‘14,17’ is telling the list_cats function not to fetch categories 14 or 17. (cat 14 is my “About” category, and cat 17 is my newly created “Not Found” category. See this thread for more info on the “Not Found” business…)
    I’m still having issues, though, keeping posts from those categories off the home page. Adding the following just after $blog = 1; in my template:
    if (empty($cat))
    $cat = -14;
    will keep any posts from category 14 from showing up on my home page. However, I’ve just discovered it breaks the post_per_page functionality and instead lists *all* other posts (no limit.) Also, I can’t find a way to use multiple categories (ex: $cat = ‘-14 -17’; doesn’t work. It only filters out the first one listed. )
    So, for the time being I’ve set the dates for my About page and my Not Found page to a time in the past so they drop off the home page. They still show up in the archives, though, but that’s another story altogether.
    I’m starting to think I should just abandon the idea and use individual pages with the same template (about.php, for example), although I hate the thought of keeping all these separate template pages synched up.
    Arrggghhh. I need food.

    I’m not sure why you’re getting an error in the dropdown_cats() function…Are you using the dropdown category list, or the regular list? I left dropdown_cats() alone since I’m not using it, but it seems it could be similarly modified.
    Here’s the whole top-part of my list_cats() function after modification, so you can see if yours matches:
    function list_cats($optionall = 1, $all = ‘All’, $sort_column = ‘ID’, $sort_order = ‘asc’,
    $file = ‘blah’, $list = true, $optiondates = 0, $optioncount = 0, $hide_empty = 1, $filter = 0) {
    global $tablecategories, $tableposts, $querycount, $wpdb;
    global $pagenow;
    global $querystring_start, $querystring_equal, $querystring_separator;
    if (($file == ‘blah’) || ($file == ”)) {
    $file = $pagenow;
    $sort_column = ‘cat_’.$sort_column;
    $query = ” SELECT cat_ID, cat_name,”;
    $query .= ” COUNT($tableposts.ID) AS cat_count,”;
    $query .= ” DAYOFMONTH(MAX(post_date)) AS lastday, MONTH(MAX(post_date)) AS lastmonth”;
    $query .= ” FROM $tablecategories LEFT JOIN $tableposts ON cat_ID = post_category”;
    $query .= ” WHERE cat_ID > 0 “;
    $query .= ” AND cat_ID NOT IN ($filter) “;
    $query .= ” GROUP BY post_category “;
    if (intval($hide_empty) == 1) {
    $query .= ” HAVING cat_count > 0″;
    $query .= ” ORDER BY $sort_column $sort_order, post_date DESC”;
    Hope this helps,

    I highly recommend PHP and MySQL for Dynamic Websites (Visual Quickpro Guide) by Larry Ullman. I’m only about a third of the way through, but it’s very clearly written and easy to follow (it is, after all, a Visual Guide.)

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Disabling a post from the “main” page’ is closed to new replies.