Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.19 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: WP Meta Menu
  4. Description: Overrides the current page menu with one selected from the custom page meta.
  5. Version: 1.0
  6. Author: Thomas Burton Sieverding
  7.  
  8.  Copyright 2010  Thomas Sieverding  (email : Jester831@gmail.com)
  9.  
  10.     This program is free software; you can redistribute it and/or modify
  11.     it under the terms of the GNU General Public License as published by
  12.     the Free Software Foundation; either version 2 of the License, or
  13.     (at your option) any later version.
  14.  
  15.     This program is distributed in the hope that it will be useful,
  16.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18.     GNU General Public License for more details.
  19.  
  20.     You should have received a copy of the GNU General Public License
  21.     along with this program; if not, write to the Free Software
  22.     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  23. */
  24.  
  25. function wp_meta_menu( $args ) {
  26.    
  27.     global $post;
  28.     $menu = get_post_meta($post->ID, 'custom-menu', false);
  29.     if(!empty($menu)) { $args['menu'] = $menu[0]; }
  30.     return $args;
  31. }
  32.  
  33. add_filter('wp_nav_menu_args', 'wp_meta_menu');
  34. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement