WordPress.org

Ready to get started?Download WordPress

Forums

Need help: List custom field from parent page in menu (2 posts)

  1. olerules
    Member
    Posted 3 years ago #

    Hi!

    I'm making a menu with drop down child's from parent page element, and would like to show a short description (custom field named 'description' from parent page) in the menu.

    Something like this;

    Home ¡ About ¡ Contact
    ¡ About me ¡ Here you can find some info
    ¡ About my girlfriend ¡ about me and my girlfriend.

    A picture of this, can be seen here; http://www.lugnt.net/
    Can anyone help me with some code?

    Thank you!

  2. olerules
    Member
    Posted 3 years ago #

    Btw, this is the code I got by now;

    function end_lvl(&$output, $depth) {
    		$args=array(
    			  'orderby' => 'title',
    			  'order' => 'ASC',
    			  'post_parent' => 0,
    			  'post_type' => 'page',
    			  'post_status' => 'publish',
    			  'posts_per_page' => -1,
    			  'caller_get_posts'=> 1
    			);
    			$my_query = null;
    			$my_query = new WP_Query($args);
    			if( $my_query->have_posts() ) {
    			  while ($my_query->have_posts()) : $my_query->the_post();
    				$link = get_post_meta($my_query->post->ID, 'link_url', true);
    				$text = get_post_meta($my_query->post->ID, 'Menytekst', true);
    			  endwhile;
    			}
    			wp_reset_query();  // Restore global post data stomped by the_post().
    
    		$indent = str_repeat("\t", $depth);
    		$output .= '</div><div class="menu_info">'.$text.'</div>';
    		$output .= "$indent</ul>\n";
    	}

    And it works somehow, but the output "$text" is the same for every dropdown.

Topic Closed

This topic has been closed to new replies.

About this Topic