Title: Custom fields as functions.php variables?
Last modified: August 20, 2016

---

# Custom fields as functions.php variables?

 *  [bozobo](https://wordpress.org/support/users/bozobo/)
 * (@bozobo)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-as-functionsphp-variables/)
 * 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

Viewing 1 replies (of 1 total)

 *  [s_ha_dum](https://wordpress.org/support/users/apljdi/)
 * (@apljdi)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-as-functionsphp-variables/#post-2836712)
 * The menu API is the slickest way. [http://wordpressapi.com/2010/11/01/menu-wordpress-3-0-theme/](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](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?

Viewing 1 replies (of 1 total)

The topic ‘Custom fields as functions.php variables?’ is closed to new replies.

## Tags

 * [custom_fields](https://wordpress.org/support/topic-tag/custom_fields/)
 * [functions](https://wordpress.org/support/topic-tag/functions/)
 * [globals](https://wordpress.org/support/topic-tag/globals/)
 * [nav](https://wordpress.org/support/topic-tag/nav/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 1 reply
 * 2 participants
 * Last reply from: [s_ha_dum](https://wordpress.org/support/users/apljdi/)
 * Last activity: [13 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-as-functionsphp-variables/#post-2836712)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
