WordPress.org

Ready to get started?Download WordPress

Forums

Custom fields as functions.php variables? (2 posts)

  1. bozobo
    Member
    Posted 2 years ago #

    I currently let Pages appear in my main navigation bar by using the includes parameter of wp_list_pages, like so:

    function sandbox_globalnav() {
    	if ( $menu = str_replace( array( "\r", "\n", "\t" ), '', wp_list_pages('include=10, 2, 13, 91, 1324, 1405, 1356, 664, 1268, 1533, 1841&title_li=&sort_column=menu_order&echo=0') ) )

    When a new page is made, I have to manually add the page ID to this list to allow it to show.

    Can anyone offer a slicker way of doing it that won't take long? I'm thinking there may be a way to collate a new Page custom fields setting into a global variable accessible to functions.php, which will create this list.

    Thanks!
    Matt

  2. s_ha_dum
    Member
    Posted 2 years ago #

    The menu API is the slickest way. http://wordpressapi.com/2010/11/01/menu-wordpress-3-0-theme/

    I am guessing you are only assigning some page to the menu but not all pages? Since by default you get all pages: http://codex.wordpress.org/Function_Reference/wp_list_pages

    If, as I am guessing, you are only assigning some page to the menu, there isn't going to be an easy way to automatically add pages to your menu unless you can work up some logic that lets the software pick pages you want and which ones you don't-- a custom meta field, a tag, a category, ID greater that N, something. Does that make sense?

Topic Closed

This topic has been closed to new replies.

About this Topic