WordPress.org

Ready to get started?Download WordPress

Forums

Menu and meta data (1 post)

  1. almemedia
    Member
    Posted 3 years ago #

    Hi I have a problem with a sub menu - I have several sub menus but want to set witch to display depending on a custom field called "MenuName". My thought is that if the field is blank the menu none would show up but I can't get it to work, I am not very good at php so it is probably a stupid mistake but I can't find any solution in the forums. The code is:

    <?php $vars = get_post_meta($post->ID, 'MenuName', true);
    
    	if($vars == ( $vars == '')) {
    		$mvars = 'none';
    	} else {
    		$mvars = $vars;
    	}
    ?>
    
    <div id="menu1"><?php wp_nav_menu( array( 'container' => 'none', 'container_class' => 'menu-header', 'theme_location' => 'primary', 'menu' => '$mvars' ) ); ?>	</div>

Topic Closed

This topic has been closed to new replies.

About this Topic