Skip to content

Instantly share code, notes, and snippets.

@morsdyce
Created August 2, 2014 22:29
Show Gist options
  • Save morsdyce/9e88db1eba916163cc23 to your computer and use it in GitHub Desktop.
Save morsdyce/9e88db1eba916163cc23 to your computer and use it in GitHub Desktop.
Sub pages menu on wordpress
<?php
if (isset($cat) && !empty($cat)) : ?>
<nav role="category-navigation">
<a href="#" id="dropdown-menu"><?php _e('Menu', 'dwframework'); ?></a>
<?php
// Query the lasts ten category posts
$category_ten_last_posts = array(
'numberposts' => 10,
'cat' => $cat,
'orderby' => 'date',
'order' => 'DESC'
); ?>
<div class="menu-menu-1-container">
<ul id="menu-category-1" class="menu">
<?php foreach (get_posts($category_ten_last_posts) as $post) : ?>
<li class="menu-item menu-item-type-custom menu-item-object-custom">
<a href="<?php echo get_permalink($post->ID); ?>"><?php echo $post->post_title; ?></a>
</li>
<?php endforeach; ?>
</ul>
</div>
<div class="clearfix"></div>
</nav>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment