WordPress.org

Forums

[resolved] New Pages Automatically Added to Nav Bar - HELP! (7 posts)

  1. jakecollier
    Member
    Posted 3 years ago #

    Hey, guys. I'm using the cp-minimalist theme (with a Child Theme, of course), and have noticed that every time I add a new page, it's automatically added to the top nav bar of the site. Not good, since I'd like to have more than just 5 or 6 pages here.

    I am no code monkey, so do any of you guys have any ideas for me? Still learning (well, I guess we all are, long as we have a pulse).

    To be honest, I don't even know where to begin finding the snippet of code that may help. Really hoping to not change themes, since I like the simplicity of this one.

    Thoughts?

    http://screenshotromance.com

  2. jakecollier
    Member
    Posted 3 years ago #

    Oh, and just a bit more clarification...

    I like the way the top nav looks. I'd just like to be able to control what goes up there and what doesn't.

  3. Ming Sheu
    Member
    Posted 3 years ago #

    I've never used that theme but it looks like it's just using wp_list_pages for the top menu.

    Since you are already using a child theme I'm assuming you know at least a bit of code.

    Look in header.php in the child theme for

    wp_list_pages('title_li=');

    Replace that with

    wp_list_pages('include=1,2,3&title_li=');

    Change 1,2,3 to the ID of the pages you want to include in the menu.

    That should give you what you want.

  4. jakecollier
    Member
    Posted 3 years ago #

    I believe that's going to work perfectly, Ming Sheu.

    One further question - for keywords' sake, I'd like to have a page displayed in the nav with a different title than the actual name of the page.

    For instance, a page is titled "How To Take a Screenshot" (a keyword I want to keep in the page title), but I'd rather the nav title be something shorter, like "Screenshot?" or "How To". Is there a "list as" tag I can use?

    Don't want to abuse your knowledge. That's my only further question. Thanks for your help.

  5. Ming Sheu
    Member
    Posted 3 years ago #

    If you want that level of control, I would recommend swapping out the wp_list_pages code with the following.

    register_nav_menu or register_nav_menus

    You would put the register_nav_menu(s) in your child theme functions.php file.

    wp_nav_menu

    Once registered, you would call wp_nav_menu in header.php

    To configure what and how items are displayed, go to Admin -> Appearance -> Menus

  6. jakecollier
    Member
    Posted 3 years ago #

    Thanks, Ming Sheu. You've been an enormous help. I'm smarter now than I was before this thread began. :)

  7. Ming Sheu
    Member
    Posted 3 years ago #

    Sure, no problem.

    I don't know your skill level so hopefully the reference links are good enough to get you started.

Topic Closed

This topic has been closed to new replies.

About this Topic