WordPress Tutorial – How to Make a “Child” Page (Subpage) and How to Hide a Link in the Pages Sidebar Widget

UPDATE – PLEASE NOTE:
If you have a “self-hosted” or third-party-hosted site instead of one hosted on WordPress.com, you may be able to use the Exclude Pages Plugin for WordPress to hide Child Page links that show in popup submenus under your main navigation links and any links that appear in your sidebar Pages navigation.

You can’t install WordPress plugins on sites hosted by WordPress.com. That’s one of the main drawbacks to hosting with WordPress.com. For those sites, this tutorial is still useful.

This beginner-level WordPress tutorial shows 1. How to make a “child” page or subpage of another page (a “parent” page) using the WordPress 2.7 editing interface. And 2. How to hide a link in the Pages sidebar widget, in other words, how to keep a link to a page from showing in the Pages sidebar widget by putting the page (post) ID number into the “Exclude” box in the Pages sidebar widget dialog box.

If you like this tutorial, you may also like: WordPress Tutorial – How to Make a Static Page Your Home Page & Hide a Double Home Page Link

Making “child” pages (subpages) is useful because you may not want all your pages to show in the main page navigation of your WordPress theme. In most themes, only “main” pages (pages that don’t have a “parent”) show up in the main page navigation. In some newer WordPress themes, child pages show up in a popup menu that appears when you roll over the main page link. And in some themes, sub-subpages show up in popup menus as well. These are sometimes called “cascading” navigation menus: sub-subpages show up in a popup menu when you roll over a subpage link.

The second part of this tutorial shows how to hide (or “exclude”) a link to a page that would otherwise appear in the links of the Pages sidebar widget. The tricky part of excluding a link is finding the page / post ID number. I show you how to do this.

Excluding a link is useful for a number of reasons. One is that when you make a static page your Home page in WordPress (by telling WordPress to diplay a Page as your Home page instead of displaying your blog posts), some themes will show the link to this static page as a second home page link in your main navigation. By making the Home page a subpage and excluding that link from the Pages sidebar navigation, you can eliminate the double Home page link.

In WordPress 2.7, you select a static page to use as your Home page using the Settings > Reading panel in the Dashboard. When you do this, be sure to create a new page to use as your Blog page. If you do not designate a page to use as your Blog page, your blog posts will no longer be visible.

How to Make a “Child” Page (Subpage) & Hide a Pages Sidebar Widget Link

39 Responses

  1. Excellent tutorial and well presented, thank you!

  2. Hello Mark,

    Sorry for this obvious question …

    I´ve been following your tutorial of how to make child pages or subpages.

    You explain for example how to create a child page of your “about page”.

    So what you get is:

    About Business Blogging 101 in China (sample page)

    What if instead of creating a subpage of your “about” you directly create a subpage of http:mcbuzz.wordpress.com??

    That´s what I want to do with my blog. I want some pages to be child pages of my home page.

    I´m not really got at explaining…. do you understand anything I´ve said?

    Thank you!.

    • @carolina
      No worries! If I understand you correctly, you only need to create a new page with Pages > Add New. When you leave that page as “Main page” – a page with no parent – it will automatically be a “child” of your home page – if you want to put it that way. A “Main page” is a child of your home page. On the mcbuzz.wordpress.com site, the Main pages (child pages of the home page) are About, Contact Us, WordPress Tutorials – Complete List, Resources, and Terms of Use.

      • Mark,
        Thanks for your reply.
        If you create a new page with Pages > Add New and leave that page as “main page” – won´t it appear in the navigation bar at the top as you have for about, contact us, wp tutoriales… etc… ? In this case I don´t want it to appear at the top. I know how to manage that but with the example you gave in your tutorial, creating a child page from “about”.

        On your mcbuzz.wordpress. com site to give you an example, your first link “How to Use a Text Widget to Customize a WordPress Sidebar” links to:

        WordPress Tutorial – How to Make a “Child” Page (Subpage) and How to Hide a Link in the Pages Sidebar Widget

        I want to manage that. In my post link some words to another page without the “about” in the middle of the url.

        I might be missing something, basic concepts of linking to another page or something……

      • @carolina
        You can definitely do that. You can create a Main page, and then you need to exclude that page from the main navigation. Some custom themes let you do that from within the Dashboard, and there are probably plugins that will enable you to do the same thing. Or you can do it manually by adding a parameter to the PHP code for the main navigation in the header.php file.

        I don’t have a tutorial for this yet. Sorry! If it’s a matter of fixing a business website, send me an email and we can discuss it.

  3. Hello Mark,

    Thanks for your message!
    I´m almost there.

    To conclude…. if you have too many main pages in your navigation bar and want to exclude pages from there you´ve got 2 ways to do that:

    1) The code way: I personally don´t feel too comfortable to do that since don´t know anything about PHP files. But you need to get something like this from the header php file:

    You need to type in your page IDs you want to exclude.

    2) Fantastic plugins!. This plugin adds a check box to include or exclude the pages you don´t want to appear.
    Exclude pages WordPress Plugin:

    http://wordpress.org/extend/plugins/exclude-pages/

    Mark, please correct!!!

    Question regarding pages in dashboard.
    Plugin and excluding pages ok. BUT, I can see from dashboard I´ve got 4 pages and 0 approved. Is something wrong?

    • @carolina
      Thanks for your comments and for pointing out the exclude pages plugin.

      I notice that the code you are trying to put into your comment is being removed by WordPress. WordPress won’t allow you to put strings of PHP code into a comment because potentially someone could put in malicious code or something that would send out spam email or something like that if it were included in the page or post.

      I haven’t figured out a great solution for this. It’s the brackets that cause the problem.

      It’s not that hard to exclude a page by editing the header.php file of your theme with a text editor. I do this in the main navigation on my http://mcbuzz.com site.

      Here’s what the code for the navigation looks like:

      ?php wp_list_pages(‘sort_column=menu_order&depth=1&exclude=142’ ); ?

      (I removed the left and right brackets that go on either end.)

      The exclude=142 is what keeps the page with that post ID number from showing in the main navigation. The other parameters are:

      sort_column=menu_order (This means that the navigation links appear in the order I assign them in the Dashboard editor under “Menu Order”.

      depth=1 (This means that I want to display only the first level (Main) pages, not subpages, in my horizontal navigation.)

      You use the ampersand ‘&’ to connect more than one parameter. If you find the wp_list_pages() in your header.php file, you can add “&exclude=[post ID number]” (without the quote marks). To see how to find the post ID number for a page or post, watch the tutorial How to Make a “Child” Page (Subpage) and How to Hide a Link in the Pages Sidebar Widget.

      Also, don’t worry about the “0 approved” next to your “4 pages” in your Dashboard under “Right Now – At a Glance”. The “0 approved” refers to the Comments submitted on your site, not the Pages. The display is a little confusing.

  4. Hi! Thank you so much for this =)

  5. Mark,
    I’ve been building a couple of site using self-hosted WordPress and various free themes. When I do the trick to hide the double Home tab, it definitely works. But then when you click on the page that has the Home page as child, the tab for that page is highlighted as well as the Home page.

    To illustrate. If I’m on the Home page, Home tab is selected. If I go to ‘About’, About tab is selected. ‘Blog’ page has Home as a child. If I go to the ‘Blog’ page, both ‘Blog’ tab and ‘Home’ tab will be selected.

    This happens on every theme I’ve tried that has tabs in the header.
    Thanks for any help.
    Todd

    • @Todd
      If you can send me your website URL so I can check it out, that would be great. If you don’t want to display it here in the comments, you can use the Business Blogging 101 Contact Form.

      Have you tried the Hide / Exclude Pages WordPress Plugin? Try that before doing anything else.

      Here’s a follow-up: If the Exclude Pages plugin does not solve the problem, you may need to edit the code for your theme. If you are comfortable viewing the source code for these pages, you can find the code for the navigation and see that the issue involves dynamic insertion of class=”current_page_item”, which causes the nav button for the current page to be highlighted or turned “on”. The problem you are having is that on the Posts Page, class=”current_page_item” is inserted twice. You want to keep it from being inserted into the Home link. Conversely, you want to make sure it is inserted into that link when you are on the Home page.

      This is definitely what I would consider an “advanced” WordPress issue. There may be a plugin that solves the problem, but I don’t know of one. The way I would solve this would be to create custom code for the navigation menu by editing header.php in your theme files.

      If you Google “current_page_item double” (without the quotes) http://www.google.com/search?q=current_page_item+double you can find some posts that help you do this. I don’t have a tutorial for it at the moment.

      http://www.vanseodesign.com/blog/wordpress/hightlight-current-page-wordpress/

      http://www.talkphp.com/general/3558-wordpress-current_page_item.html

      Sorry I can’t be of more help.

      • Mark,

        Actually that’s great help. I’ve been testing many different themes while learning about WordPress. It seems to me that this is the default behavior with themes that have tabs. Someone will probably come up with a solution to this sooner or later I would think. The fix for double Home tabs ends up creating this issue with navigation.

        Todd

  6. i have made Tutorial Parent Page(just testing..) as a main page..then i made a new page called Tutorial Child Page (also just to test) and insert it under Tutorial Parent Page.Unfortunately,the child page is not under the parent page..it turn out to be a page which tagged as uncategorized..i have no idea how to change the uncategorized tag into tutorial tag (so that all the tutorials will be under Tutorial category)
    then i start using post and make Tutorial (post not page).After that i start making a post such as Tutorial#2(child title) and insert it under Tutorial (parent title)..this time i am able to tag it under Tutorial tag.Luckily all the tutorial posts(child title) are under TUtorial(parent title).
    the questions are:
    1)why my child title page can’t be inserted into parent page.
    2)how do i change the uncategorized tag page into Tutorial category..(i’m talking about page and not post).

    Although the problem (inserting child title into parent title) solve when i use post, i still want to figure out how to do it using page..
    thanks in advance

    http://www.archi-sketch.com

    • @archisketch
      It’s not possible to assign a category to a page. Nor is it possible to assign a tag to a page. Only posts can have categories and tags. So your question #2 might be a matter of confusing “page” with “post”.

      Likewise, it sounds like your “child page” in question #1 might actually be a post, which would explain why you can’t make it a subpage.

  7. Mark,

    It seems necessary to ALSO have a navigation plugin. Yes? If so, which one do you use? There are many.

    Without the navigation plugin, the subpages do not show up in a sidebar, it seems. At least, they’re not showing up in mine.

    Jane

  8. The problem doesn’t seem to be creating the child page; it seems to be getting the child page to appear when one is on the parent page. I can create my child page, but cannot get it to appear. The WordPress tells you how to create a child page and it’s there, but it simply does not appear when one is on the parent page. In WordPress 2.8 there is no easy way to check or change the “depth” of the nesting.

    • Hi Jane,
      Thanks for your questions. 1. Can you share the URL for your site? 2. What theme are you using?

      Some themes will show child pages in navigation – either in the main nav at the top of the page, or in the sidebar, or both. Others don’t.

      The “Exclude Pages” plugin by Simon Wheatley is very good. It lets you hide pages in navigation, but it sounds like you want to do the opposite.

      • Hi Mark. Thanks.

        The URL is dogsdontlookbothways.com/joeys_blog. The theme is Albion. You are correct, I want to do the opposite: I would be happy to show (then worry about excluding).

        Also, if it helps, I have this code in the header:

        /* Header ++++++++++++ */
        .header { width: 810px; padding: 25px 30px 10px 30px; margin-bottom: 10px; border-bottom: solid 1px
        etc.

        Thanks zillions.

        Jane

      • Hi Jane,
        Have you added the Pages widget to your sidebar?

        I loaded the Albeo theme (your theme) on a test site and subpages do display in the sidebar Pages navigation:
        http://mcbuzz.info/about/graphic-design/

        I also added the Exclude Pages plugin, and using that I was able to hide the link to the “Graphic Design” page in the sidebar nav. You can see only one subpage link in the sidebar nav (”Web Development”). The other is hidden using the plugin.

  9. Mark,

    That did it! The reason I never put the pages widget in the side bar is because it seemed repetitive (as the pages are listed along the top already). Now I see its function.

    Is that the only way to access a page? Through the page navigation?

    Then I guess the next challenge is to figure out how to do those drop down menus from the parent pages. Albion has the pages listed along the top. With only one sidebar for Albion, I don’t want to put everything there; it becomes dysfunctional!

    Thanks,

    Jane

    • Right. The dropdown navigation for subpages is a great feature. I don’t think you want to try to add that yourself. It’s complicated. Have you looked at some of the “premium” WordPress themes? See the Business Blogging 101 Resources page. Several of these have very good dropdown nav for subpages.

      • You are correct; I saw the code today and it is complicated! Lots of backing up databases…And then if it still doesn’t work….Yikes! Changing themes may be in the cards down the road!

  10. Mark,

    Your sidebar navigation looks different: First, it has the little arrows that points to and indicates child pages. Secondly, it has the hover feature! Delightful!

    I’m guessing you used some widget to make this magic appear! Care to share?

    Jane

  11. Thanks very much – this has been stumping me for several months now!

  12. hi.. I’ve been trying to create a child page under a parent page.. but it’s not working.. i have chose the right to be its parent but when i visit the site when i hover the mouse in the parent page, the child page is not appearing..

    somebody help me please.. i have a deadline to make.. thanks

  13. I am trying to set up my first blog.
    I would like to have two main pages called
    “my novel” and “my short stories”
    Within these pages I would like to have “Chapters No 1-18, And “Various titles” as child pages, but only want visitors to get access to the child pages from the main pages.
    I have tried to follow your tutorial but am having difficulty.
    My url is http:jebscot.wordpress.com
    Can you please help me

  14. What happens if your subpage shows up in the navigation bar under the parent page you listed/

    For example, if I put HOME under ABOUT US. It will disappear in the site navigation (widget) but when the mouse hovers the ABOUT US tab underneath the subpage “Home” shows up still.

    • @6thsensemarketingfirm
      Excellent question. This did not used to be a problem on WordPress.com because their were no themes with popup subnavigation.

      Fortunately, on the theme you are using, “monochrome”, you have “Theme Options” that allow you to exclude pages from the navigation menu. The only slightly tricky part is that you need to find the Page ID (also called the Post ID) for the page you want to exclude.

      In my How to Make a “Child” Page (Subpage) and How to Hide a Link in the Pages Sidebar Widget tutorial, I show how to find the Page ID. Then, in your Dashboard, go to Appearance > Theme Options, scroll down to “Exclude Pages (Page ID’s you don’t want displayed in your header navigation…” Put that number into the box and click Save Changes. BOOM.

      I just noticed that in my Google Chrome browser, you cannot see the Page ID’s because the area for the status message is not wide enough. Apparently no one using WordPress at Google has a need to exclude pages, or they’re not using Chrome.

  15. Perfect! Thank you so much for helping! That really helped.

    • @6thsensemarketingfirm
      Glad that worked for you.

      On another note, checking out your blog/website, I see that you have a 6thsensemarketingfirm.wordpress.com address.

      I feel compelled to give you my 2 cents about hosting a site on WordPress.com. The short version is this: register your own domain name and use it for your site. It’s cheap, relatively easy, and you will be so glad you did it.

      Here are the instructions:
      http://en.support.wordpress.com/domain-mapping/register-domain/

      Believe me, you need to do this if you plan to use your site for more than a few weeks. I was going to say “…if you plan to use your site for more than a hobby,” but this site, Business Blogging 101, started as more or less a hobby, and I am now feeling some serious pain because I have lots of visibility (“link equity”, PageRank, etc.) built up at mcbuzz.wordpress.com – but I really need to move the site!

      Had I started with my own domain, I would have none of those problems.

  16. Hi Mark,
    Thoroughly appreciate your tutorials, they are very helpful for even a beginner (like me!)

    My issue is:
    I am able to create and publish pages, and even child pages. But, when I publish child pages, they show up in my navigation bar (and throw everything out of whack all over my page). If I mark the child pages as “private”, everything goes neatly back into place, but of course then no one can access my child pages.

    I know it has something to do with my template, but I cannot figure out how to hcange it, and it’s REALLY frustrating me because have LOTS of content to add, people hitting my site, and yet my child pages are private.

    Grrr.
    Any suggestions you can provide would be MUCH appreciated.

    Thanks,
    t.

    • @tdostaler
      Thanks for your question! Since you have a self-hosted WordPress site, you can use the Exclude Pages Plugin for WordPress that I mention at the beginning of this post. That will keep the links out of the navigation bar and out of the Pages sidebar navigation. If you want to keep Child pages links out of the navigation bar but not the Pages sidebar, you may need to modify the header.php file of your theme.

      Modifying header.php is a little tricky if you haven’t tried it before. You need to find
      <?php wp_list_pages( … ); ?>
      and set – or add – the depth to 1 so it looks something like
      <?php wp_list_pages( ‘depth=1&…’ ); ?>

      My bet is that the Exclude Pages plugin will work for you. Let me know if not.

  17. It worked! It worked!

    lalala

    You and Joannie Rochette are my two new heroes.

    Thanks a million!
    t.

  18. Hey there — so, this is working out perfectly so long as I actually want my pages listed on the sidebar at all. The thing is, I don’t. I don’t want a site navigation there AT ALL, and the only way to hide certain pages is to include the pages widget.

    If I make the pages widget inactive, then my blog appears as it does right now (knehlspoco.wordpress.com). My static homepage is a subpage of my “who I am,” page, which is really obvious right now, but I don’t want that to be visible on the right hand sidebar. I can make that unknown by incorporating the pages widget, however incorporating the pages widget means there’s a separate navigation on the right hand sidebar, which I don’t want since there’s a suitable navigation at the top.

    Any answers? Thanks so so much!!

    -kristin