How do i get the date from my posttype to show in my menu
-
For the life of my i cannot figure out how to retrieve the start date of the event from my custom posttype events table to show in the output of my custom menu.
i would like the menu to show up like this.
<ul> <li>event 1 | 01.02.2013</li> <li>event 2 | 01.02.2013</li> <li>event 3 | 01.02.2013</li> <li>event 4 | 01.02.2013</li> <li>event 5 | 01.02.2013</li> </ul>
but i cannot get the date to show no matter what i try.
function event_custom_menus() { $menu_name = 'home-locations-list'; // specify custom menu slug if (($locations = get_nav_menu_locations()) && isset($locations[$menu_name])) { $menu = wp_get_nav_menu_object($locations[$menu_name]); $menu_items = wp_get_nav_menu_items($menu->term_id); $menu_list = '<nav id="c6 hp-loc-list-custom" class="locations-list clear" style="">' ."\n"; $menu_list .= "\t\t\t\t". '<ul style="">' ."\n"; foreach ((array) $menu_items as $key => $menu_item) { $post_meta_data = get_post_custom($post->ID); $race_date = get_post_meta($post->ID, '_event_start_date', true); $title = $menu_item->title; // $race_date = date("m.d.y", strtotime($post_meta_data['_event_start_date'][0])); //$today = date("m.d.y"); $url = $menu_item->url; $menu_list .= "\t\t\t\t\t". '<li style="" class="tcr"><a class="notcr '. $title .' " href="'. $url .'">'. $title .' '.$race_date.'</a></li>' ."\n"; } $menu_list .= "\t\t\t\t". '</ul>' ."\n"; $menu_list .= "\t\t\t". '</nav>' ."\n"; } else { // $menu_list = '<!-- no list defined -->'; } echo $menu_list; }
[Please use the code buttons – your code has likely been corrupted]
- The topic ‘How do i get the date from my posttype to show in my menu’ is closed to new replies.