Skip to content

Instantly share code, notes, and snippets.

@LinzardMac
Created March 6, 2013 22:05
Show Gist options
  • Save LinzardMac/5103525 to your computer and use it in GitHub Desktop.
Save LinzardMac/5103525 to your computer and use it in GitHub Desktop.
// Filter wp_nav_menu() to add link to recent lottery
function new_nav_menu_items($items) {
// Get the most recent post
$the_query = new WP_Query( 'posts_per_page=1' );
// Pull the excerpt
while ( $the_query->have_posts() ) : $the_query->the_post();
$latest_link = '<li> <a href="' . get_permalink() . '>Lotteries</a></li>';
endwhile;
$items = $latest_link . $items;
return $items;
}
add_filter( 'wp_nav_menu_items', 'new_nav_menu_items' );
@jbotte
Copy link

jbotte commented Mar 6, 2013

                    $latest_link = '<li> <a href="' . get_permalink() . '">Lotteries</a></li>';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment