How to create a Dynamic Menu Title using “Title_li” in WP_LIST_PAGES
-
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_metaIf anyone has done this before, or knows how to do it, please share your wisdom!
My Webpage is located at https://www.LeftWingHate.com
- The topic ‘How to create a Dynamic Menu Title using “Title_li” in WP_LIST_PAGES’ is closed to new replies.