Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I know that WP3 offers wp_nav_menu and description field but I was wondering if it is possible to alter wp_page_menu to echo desired meta key value next to the page link in format that is adjustable.

Hope my question is clear.

Thanks

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

There is no easy way to alter the vale of each li in the wp_page_menu but there is a way to do it without creating your own function or custom walker using the_title filter hook.

so create your function , something like this:

function custom_menu_title($title,$post_id){
  return $title . ' ' . get_post_meta($post_id,'meta_key',true);
}

and you hook it before you call wp_page_menu and remove it right after so:

add_filter('the_title','custom_menu_title',10,2);
wp_page_menu(array(...));
remove_filter('the_title','custom_menu_title',10,2);
share|improve this answer
    
Will check the solution and answer shortly after. Thanks man. –  daniel.tosaba Aug 20 '12 at 20:47
    
How would you display desired meta key value using custom Walker class? No need for whole function just part where you add value to the variable. Thanks –  daniel.tosaba Aug 24 '12 at 4:57
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.