Wordpress Page Menu code

As requested, the code for page menu tabs - leaving open the possibility of using the ’sliding doors’ technique - put it in a theme’s functions.php, and the usage, if not too obvious, would be something like…

<ul id=”tabmenu”>

<?php echo buildMenu(); ?>

</ul>

function buildMenu(){
global $wpdb, $table_prefix;

$menu = ‘<li><a href=”‘.get_option(’siteurl’).’/” title=”Home”><span>Home</span></a></li>’;

$pages = $wpdb->get_results(”SELECT ID, post_title as title, guid FROM “. $table_prefix .”posts WHERE post_type=’page’ AND post_status=’publish’ ORDER BY ID”);

foreach ($pages as $page){

$url = (empty($page->guid)) ? get_option(’siteurl’) . ‘/?page_id=’ . $page->ID : $page->guid;

$menu .= sprintf(’<li><a href=”%s” title=”%s”><span>%s</span></a></li>’, $url, $page->title, $page->title);
}
return $menu;
}

Bookmark:
These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Google
  • Facebook
  • Furl
  • NewsVine
  • Reddit
  • StumbleUpon
  • Sphinn
  • Technorati

No Comments

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment