Skip to content

Instantly share code, notes, and snippets.

@gubi
Created January 31, 2014 22:06
Show Gist options
  • Select an option

  • Save gubi/8744221 to your computer and use it in GitHub Desktop.

Select an option

Save gubi/8744221 to your computer and use it in GitHub Desktop.
<!-- Begin -->
<?php
$menu_name = 'primary';
$locations = get_nav_menu_locations();
$menu = wp_get_nav_menu_object($locations[$menu_name]);
$menuitems = wp_get_nav_menu_items($menu->term_id, array('order' => 'DESC'));
?>
<?php
$count = 0;
foreach((array) $menuitems as $item) {
// get page id from using menu item object id
$id = get_post_meta($item->ID, '_menu_item_object_id', true);
$shortDesc = get_post_meta($page->ID, 'shortDesc', true);
// set up a page object to retrieve page data
$page = get_page($id);
$link = get_page_link($id);
if($count <= 5) {
?>
<div id="list-subsites">
<div class="childPageLink">
<?php
echo '<h2><a href="' . $link .'" class="title">' . $page->post_title . '</a></h2>';
if ($shortDesc) {
echo '<p>' . $shortDesc . '</p>';
echo '<a href="' . get_page_link($page->ID) . '" class="readon">Weiterlesen</a>';
} else {
echo '<a href="' . get_page_link($page->ID) . '" class="readon">Weiterlesen</a>';
}
?>
</div>
</div>
<?php
}
$count++;
}
?>
<!-- End -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment