WordPress.org

Ready to get started?Download WordPress

Forums

How can I hide a page ? (25 posts)

  1. rvblog
    Member
    Posted 9 years ago #

    I posted and earlier question "sidebar on separate page" but due to lack of responses, maybe that's impossible to code.

    So my new question is this:

    How can I prevent a certain page that was created with the "Create Pages" option in WP 1.5 from being displayed in the sidebar under the "Pages" section.

    Example:

    From this:

    Pages

    Heading South
    Last Winter
    Menu
    Ready To Travel

    To this:

    Pages

    Heading South
    Last Winter
    Ready To Travel

    In other words, the Menu page still exists in the database, you can link to it from a navigational menu, you can display the sidebar info in the menu page, ...

    But,

    The page itself is not displayed on the index page under the "Pages" section.

    Is this possible to do ?

    Thanks,

  2. NuclearMoose
    Member
    Posted 9 years ago #

    rvblog,
    I don't think your primary request is impossible to do. Given the high traffic on the forums these days, it seems that some threads are disappearing off of the radar rather quickly.

  3. rvblog
    Member
    Posted 9 years ago #

    How can I find out how to do it ?

    Or,

    Where can I go to read up on it?

    Because I don't know how to do what I'm trying to accomplish, I don't know what I should be searching for on the internet in order to find the necessary articles or information that I need to explain the steps that I need to take.

    I suspect you can do it with php ? "if" something - "then not" something else - and all that stuff.

    If someone can set me off in the right direction, I would appreciate it.

    Thanks

  4. NuclearMoose
    Member
    Posted 9 years ago #

  5. rvblog
    Member
    Posted 9 years ago #

    I read the link at boren.nu and it doesn't look like it applies in my case.

    In that article, he talks about being able to load different templates based on the type of query being made - but it is still based on either a post or a page being created beforehand.

    For the templates that he talks about to work you need to have a page created (static or virtual) or a post entered into the database in order to call the template and display it.

    I made various templates, all with no problem at all.

    I made one called menu.php that included the "get header.php", "get footer.php", and it also included the "get sidebar.php" which is what I want to do. I also created a link on a navigational bar to link to the page called menu. Everything worked fine except for one thing:

    The only problem with that (and that's what I'm trying to prevent) is this new menu page is listed under the "Page Section" (in the WP 1.5 default Kubrick theme) with all the other article pages and all the other sidebar info.

    I'm trying to create a menu page to act like a sort of content or index page but I don't want it to be listed with all the rest of my virtual article pages. I do not want that menu page to be listed or visible on any page. I just want to click on the navbar button and a page appear with all the sidebar stuff included.

    Instead of a dual column page with post section on the left and sidebar section on the right, I want a single column page with index on one page and the sidebar on another page. But ideally, I would like the menu.php to function just like an index.php file.

    I've tried to create a situation where, when I type in http://www.mysite.com/menu.php, I get a page with the sidebar info in it. Everything I've tried so far gives me a 404 error page when I try to access the menu.php file.

  6. RustIndy
    Member
    Posted 9 years ago #

    If you created a page in WP1.5 named "menu" using WPs page feature, then your actual URL would be http://www.mysite.com/menu/.

    Unfortunately, after looking at the WP source, there doesn't seem to be an easy way to hide a page currently. I'm looking into adding the exclude argument from wp_list_cats to the wp_list_pages routine though, to see if it works :)

  7. rvblog
    Member
    Posted 9 years ago #

    Yes, that's exactly how it works. The ~http://www.mysite.com/menu` is actually a link to a virtual page that was created and is located in the database. It is not a menu.php like the index file is.

    I'm glad you understand what i'm trying to do and i look forward to that exclusion feature being added if it is at all possible. Other people may also have the need to hide certain pages for various reasons.

    How will I know if and when the exclusion feature is added to the wp_list_pages routine. Is the another forum to watch for it?

    Thanks

  8. RustIndy
    Member
    Posted 9 years ago #

    I'm a liar!

    The tag you call from your template, wp_list_pages, will accept an exclude parameter :)

    So, in your admin interface, look up the ID number of the page you want to make invisible, then change the tag from:
    <?php wp_list_pages('title_li=<h2>' . __('Pages') . '</h2>' ); ?>
    to:
    <?php wp_list_pages('title_li=<h2>' . __('Pages') . '</h2>&exclude=69' ); ?>
    for example :)

  9. RustIndy
    Member
    Posted 9 years ago #

    The exclude support was already in the routine, just buried a little compared to the wp_list_cats one so I didn't see it until I started digging for the thing :)

  10. rvblog
    Member
    Posted 9 years ago #

    RustIndy:

    I would still like to know ( if for anything else but to satisfy my curiousity):

    Can a menu.php be coded in such a way to act like an index.php file so that you can link to it without having to create a static or virtual page ??

    Much like an index.php file calls the sidebar.php - have a menu.php call the sidebar.php instead.

  11. rvblog
    Member
    Posted 9 years ago #

    Sorry, I was posting as you were replying.

    Thank you very, very much for the info - you just alleviated a big headache that's been hounding me for days.

    Much appreciated, and I'll give your answer a try.

    Take care.

  12. RustIndy
    Member
    Posted 9 years ago #

    Create a template file in your theme folder and name it menu.php (any name is good, really). It should contain the following lines:

    <?php
    /*
    Template Name: Menu
    */
    ?>

    <?php get_header(); ?>

    <div id="content" class="widecolumn">

    <h2>Menu:</h2>
    <?php get_sidebar(); ?>

    </div>

    <?php get_footer(); ?>

    (this is using the 1.5 default template as an example).

    Then, in the admin section, create a new page (or edit the menu page you've already created there), and change the template to menu. Viola :)

    I think....

  13. rvblog
    Member
    Posted 9 years ago #

    Thanks, and yes, you're right. That works because I already tried it. It was just the exclude code that I knew nothing about. Know I know thanks to you.

    (note: I eliminated reference to class="widecolumn" because I'm converting the 1.5 default Kubrick into a one column layout)

    And thanks to everyone else who shared in my question. Someday, I'll be able to return the help

  14. rvblog
    Member
    Posted 9 years ago #

    Someone just sent me a message telling me that I did help out by asking the question in the first place.

    Cool

  15. rvblog
    Member
    Posted 9 years ago #

    @RustIndy"

    How would I exclude 2 different pages?

    Say for pages with ID 69 and 96 ? - Like this ?

    <?php wp_list_pages('title_li=<h2>' . __('Pages') . '</h2>&exclude=69', 96' ); ?>

  16. NuclearMoose
    Member
    Posted 9 years ago #

    I think that this thread would work really well as an addition to Codex!

    RustIndy...would you be willing to take a crack at it?

  17. rvblog
    Member
    Posted 9 years ago #

    @RustIndy:

    Damn it, it did't work.

    I created a new template called menu.php, created a new page in WP called menu (with ID # 16), edited the sidebar.php file and included the "&exclude=16" code in the file, then uploaded.

    The address http://www.mysite.com/menu opened the menu.php template ok, the header and footer files were also included ok, the title <h2>Menu</h2> appeared on the screen on, ...

    But then I got this:

    Parse error: parse error, unexpected '=' in

    I'm sure I followed your example to a T - even tried including a space between the end bracket and the & character and that didn't work either.

    Any ideas ??

  18. RustIndy
    Member
    Posted 9 years ago #

    Moose, yup, as soon as we nail it down ;)

    <?php wp_list_pages('title_li=<h2>' . __('Pages') . '</h2>&exclude=69,66' ); ?>
    would exclude pages 69 and 63. Make sure there's no single-quote between the numbers. It's the exact same syntax as the exclude argument for wp_list_cats.

    Your exact line in the sidebar.php template file should read:
    <?php wp_list_pages('title_li=<h2>' . __('Pages') . '</h2>&exclude=16' ); ?>

    Just copy and paste :) Let me know. It's possible WP doesn't like this because you're ON page 16 but it's trying to exclude it from the pagelist in the sidebar.

    EDIT: Gads I hate posting code in this thing :(

  19. RustIndy
    Member
    Posted 9 years ago #

    And i'm not editing it again!!! Obviously, I meant pages 69 and 66 in that top paragraph :(

  20. rvblog
    Member
    Posted 9 years ago #

    Yes, I did it exactly like that. I inserted:

    <?php wp_list_pages('title_li=<h2>' . __('Pages') . '</h2>&exclude=16' ); ?>

    and got the error:

    Parse error: parse error, unexpected '=' in

  21. RustIndy
    Member
    Posted 9 years ago #

    Weird - just tested it and it worked fine here.

    http://russ.innereyes.com/menu.txt <-- an example menu template

    http://russ.innereyes.com/sidebar.txt <-- the line for sidebar.php to exclude page 16 from the menu

    These are exactly what I used (except my menu.php file has the Kubrick div tag in it) and it worked fine (looks stupid, but works).

  22. rvblog
    Member
    Posted 9 years ago #

    Yes it works fine now

    Your first example template had this code:

    <?php
    /*
    Template Name: Menu
    */
    ?>

    <?php get_header(); ?>

    <div id="content" class="widecolumn">

    <h2>Menu:</h2>
    <?php get_sidebar(); ?>

    </div>

    <?php get_footer(); ?>

    Your second example, the one I just used had this:

    <?php
    /*
    Template Name: Menu
    */
    ?>

    <?php get_header(); ?>

    <h2>Menu:</h2>

      <?php get_sidebar(); ?>

    <?php get_footer(); ?>

    Maybe including the <div> in the first example caused the error, and eliminating it in the second example corrected the problem.

    Regardless, it now works the way I want it to and I thank you for having the patience and sticking it out with me through this issue

    Thanks tons

  23. RustIndy
    Member
    Posted 9 years ago #

    No problem :)

    Actually, thanks to the wonky way this forum makes you post code, my example template file above ended up with a lot of double-quotes instead of single-quotes. That's likely what the problem was, and why I just slapped those text files on my server :)

    Have fun!

  24. lanval
    Member
    Posted 9 years ago #

    It's been a while, so I thought I would refresh this thread...

    I'm a beginner with WordPress, and although I get the manual exclusion mentioned by rvblog on 2005-01-12, I was wondering if anyone has found/created a plugin that would allow you to hide pages from the dashboard when creating or editing a page.

    Cheers!

  25. XratedFozzibaer
    Member
    Posted 8 years ago #

    The exclude code works in most cases but if you have a main page (parent page) with some subpages and you exclude the main page an error occures. With cats it's possibly to hide all by hiding the top category.
    With pages not?
    If I exclude each subpage too, the problem doesn't occure.
    But I don't wan't to change the exclude code each time I create a new subpage.
    Any suggestions would be really welcome.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.