• I want to display the Title of the Current Parent Page as the Title of my Vertical Menu Listing no matter which Child of that parent is displayed. To create the Dynamic Menu itself, When I create a page, I make it a child of a particular Parent Page, I have a Custom Field attached to the page that has the ID Number of the Parent Page it is a Child of, I then use the following PHP code on my right Sidebar to only display Child’s of that parent:

    <?php /* If this is Page and not a posting, comment, catagory, or bloglist */ } elseif ( is_page() ) { ?>

    <!– Begin page listing for Dynamic NewsWires –>
    <?php
    if($section_id = get_post_meta($page_id, ‘section’, $single = true))
    {
    wp_list_pages(‘depth=3&sort_column=menu_order&title_li=&child_of=’.$section_id );
    }
    ?>
    <?php } ?>

    What this code does is allow for dynamic menus on my right sidebar. If I select Pages (Currently I have two Parent Pages, one is titled “News Wires” and the other is Titled “US Goverment Wires”). I Have the Parent Pages listed on the top Horizontal menu. When you click on the menu the Parent Page will display in whole and on the right sidebar, all the child pages of that parent page will display. What I would like to do is to actually use the “Title_Li” to actually Display the Parent Page Title Text.

    In this way, in the “Manage Pages” I can create Parent Pages and then assign childs to that page, the Parent Page will automatically show up on my Top Horizontal menu and on the Right Sidebar, the Title of the listing will be the Parent Page and if I click on one of the Child pages, the listing on the right will still show the Parent Page title at the top of the listing.

    Example:

    My Parent Page (ID=20) has a Title Called “News Wires”. I have several Child Pages called “AP Wires”, “ABC Wires”, “CBS Wires”, etc..

    While on the Parent Page, the Menu would Display as follows:

    NEWS WIRES
    ———-
    AP WIRES
    ABC WIRES
    CBS WIRES
    ETC..

    If I click on AP Wires, I want the Menu on the Right to display as:

    NEWS WIRES
    ———-
    AP WIRES
    ABC WIRES
    CBS WIRES
    ETC..

    as you can see.. NO Change in the Menu Title, it takes it’s name from the Parent of children.

    NOW, If I click on my Horizontal Menu for “US GOVERMENT WIRES”, the Vertical Menu on the Sidebar will Automatically Display as follows:

    US GOVERNMENT WIRES
    ——————-
    US State Dept
    White House
    ETC..

    If I click on “White House” I want to Menu to display the following:

    US GOVERNMENT WIRES
    ——————-
    US State Dept
    White House
    ETC..

    Again, Exactally the same, and totally dependant on what the Parent Page’s name is and what the parent of the Children are.

    I have searched and searched looking for any page tag that will do this, but all of the applicable tags do NOT have the ability to allow the user to insert the ID of the page you want the information from, they all work exclusivly with the “current” page which makes this almost impossible.
    the_ID
    the_title
    single_post_title
    the_title_rss
    the_content
    the_content_rss
    the_excerpt
    the_excerpt_rss
    previous_post
    next_post
    posts_nav_link
    the_meta

    If anyone has done this before, or knows how to do it, please share your wisdom!

    My Webpage is located at https://www.LeftWingHate.com

Viewing 5 replies - 1 through 5 (of 5 total)
  • I’m not sure yet what you are asking.

    I want to display the Title of the Current Parent Page as the Title of my Vertical Menu Listing no matter which Child of that parent is displayed.

    US GOVERNMENT WIRES
    -------------------
    US State Dept
    White House
    ETC..

    If I click on "White House" I want to Menu to display the following:

    US GOVERNMENT WIRES
    -------------------
    US State Dept
    White House
    ETC..

    Did you mean to type
    White House
    ——————

    Because the your example above is what your website does now.
    So if I click on Us Gov’ Wires and then White House, you want me to see a menu of the White House feeds in your sidebar. Right?

    Thread Starter rudeseal

    (@rudeseal)

    What it shows right now is just the Child Pages on the Menu to the sidebar, it does not show the title name of the parent Page on top of the menu which is what I want done:

    Currently:

    No Menu Title is
    Shown <—Parent Title

    US State Dept <– Child Page Link
    White House <– Child Page Link
    ETC.. <– Child Page Link

    If I click on “White House” I want the Menu to display Like the following:

    US GOVERNMENT WIRES <– Parent Title
    ——————-
    US State Dept <– Child Page Link
    White House <– Child Page Link
    ETC..

    When I visited your site I missed that your sidebar doesn’t have the Parent Title listed.

    I’m still newbish – the only thing I can think of is using wp_list_pages with a depth to only allow the parent Page. But it would have to be a separate call – in its own div and the sidebar list showing the childs would stay in place.

    Other than that, it would have to be hard coded into a heading h1 or h2, for example, or a p tag.

    wp_list_pages(‘sort_column=menu_order&depth=1&title_li=)

    Thread Starter rudeseal

    (@rudeseal)

    That does not help much, but thank you for trying!

    Another newbie here… I’m using the vSlider theme and this does just that.
    header.php:
    <?php wp_list_pages(‘sort_column=menu_order&depth=1&title_li=’); ?>

    sidebar.php
    <!-- Show subpages, if available -->
    <?php
    if (is_page() && $post) {
    $current_page = $post->ID;

    while($current_page) {
    $page_query = $wpdb->get_row("SELECT ID, post_title, post_parent FROM $wpdb->posts WHERE ID = '$current_page'");
    $current_page = $page_query->post_parent;
    }

    $parent_id = $page_query->ID;
    $parent_title = $page_query->post_title;
    $test_for_child = $wpdb->get_results("SELECT * FROM $wpdb- >posts WHERE post_parent = '$parent_id'");

    if($test_for_child) {
    ?>

    <div class="hr"></div>
    <div class="sidebar">
    <a href="<?php echo get_settings('siteurl') . '/' . get_page_uri($parent_id) ?>"><h2><?php echo $parent_title; ?> </h2> </a>

    <ul>
    <?php wp_list_pages('sort_column=menu_order&title_li=&child_of='. $parent_id); ?>
    </ul>
    </div>
    <?php } } ?>

    The full code is available at: https://irui.ac/cool-stuff/vslider

    Good luck!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to create a Dynamic Menu Title using “Title_li” in WP_LIST_PAGES’ is closed to new replies.