WordPress.org

Ready to get started?Download WordPress

Forums

Set no link for parent pages (6 posts)

  1. WaRoX
    Member
    Posted 5 years ago #

    Hello!
    I need a menu of pages, where parent page contain no link and different style. For example:
    I have 3 pages, where 1 of them is parent for other:

    About company
    -History
    -Management

    To create 2 subpages I have to create page "About company". But I need not this page! "About company" should be only the heading for another pages and shouldn't link on the page. So, I need to change style of specific pages. Note that not all parent pages should be headings. "About blog" page can be in the same hierarchy as "About company", but the first should be the page and the second is heading for other pages.

  2. izdale
    Member
    Posted 5 years ago #

    BUMP

    I have found several topics throughout the support section asking this same question, and none of them have been answered. It should not be so difficult to do such a seemingly simple thing!! I am also trying to figure out how to make a parent page not contain a link. ANYONE?

  3. izdale
    Member
    Posted 5 years ago #

    Sorry about the repeat posts, I didn't show the posts as being added to the topic, so I kept clicking post. Sorry. I just made the rest blank, although I wish I could delete them.

  4. izdale
    Member
    Posted 5 years ago #


  5. izdale
    Member
    Posted 5 years ago #


  6. izdale
    Member
    Posted 5 years ago #


  7. sman_not_a_programmer
    Member
    Posted 5 years ago #

    Howdy,

    Disclaimer: I am not a programmer. This code will be ugly. I pieced it together from :
    http://codex.wordpress.org/Function_Reference/get_pages
    http://wordpress.org/support/topic/89781

    I wanted to do the same thing. Turns out it is a pretty basic code. It still took me hours to figure out.

    I put this in my sidebar for all pages/posts.

    <?php
      $pages = get_pages();
      foreach ($pages as $pg) {
        $pg_name = $pg->post_title;
        $pg_parent = $pg->post_parent;
        $pg_id = $pg->ID;
    
            if( empty($pg_parent) ) {
    ?>
    <h2>
    <?php
                 echo $pg_name;
    ?>
    </h2>
    <?php
                 wp_list_pages("title_li=&child_of=$pg_id");
    ?>
    <br />
    <?php
              } else {
             }
    }
    ?>
  8. dmathews
    Member
    Posted 5 years ago #

    Hi Sman ~

    I've run into the same problem where I don't want the parent page to have a link. I'm currently using wp 2.6.3 and I've tried your code in my "header.php" file. The following is the original code from my file:

    <ul id="nav">
    
    <li><a href="<?php echo get_settings('home'); ?>Home</a></li>
    	<?php wp_list_pages('title_li=&depth=4&sort_column=menu_order'); ?>

    I've used your code and it's not working for me. Actually, except for the home page, I can't click on any page. Is there a way to mimic my original wp_list_pages('title_li=&depth=4&sort_column=menu_order') code? I need your help.

    Denny.

  9. defdumbandblind
    Member
    Posted 5 years ago #

    I need a menu of pages, where parent page contain no link and different style. For example:
    I have 3 pages, where 1 of them is parent for other:

    About company
    -History
    -Management

    To create 2 subpages I have to create page "About company". But I need not this page! "About company" should be only the heading for another pages and shouldn't link on the page. So, I need to change style of specific pages. Note that not all parent pages should be headings. "About blog" page can be in the same hierarchy as "About company", but the first should be the page and the second is heading for other pages.

    Man....I've been searching for an answer for this for weeks now and I still can't come up with anything!!

    I also need to know how, in a subnav bar situation as I have with the Revolution Pro Theme by Brian Gardner, I can create child CATEGORIES (not pages) and have them listed and linkable in a drop down menu list, while the parent category has no linkability!

    Example:

    MENU
    - Breakfast
    - Lunch
    - Dinner

    In this example, I need the "Breakfast, Lunch and Dinner" categories to link out, but the parent, "Menu" does not need to link to an archive of all three categories, slopped on to one page.

    Does this make sense? I just would like to have the three sub categories filed under "Menu", but have Menu just act as a Category title. No link to it.

    Please help!!

  10. Technokinetics
    Member
    Posted 5 years ago #

    The Page Lists Plus plugin lets you unlink items in Page lists, so can be used to do what most of you need. You should just need to install and activate the plugin, and then uncheck a box on the edit screen and save for each Page that you want to unlink.

    I have a version of this that works with Category lists too, but haven't yet released it. If you'd like to help test it, then please email me at tim@technokinetics.com.

    - Tim

Topic Closed

This topic has been closed to new replies.

About this Topic