Skip to content

Instantly share code, notes, and snippets.

@jackfearing
Created January 31, 2023 00:14
Show Gist options
  • Save jackfearing/e892078bd1c369af3658c215d29b4eb9 to your computer and use it in GitHub Desktop.
Save jackfearing/e892078bd1c369af3658c215d29b4eb9 to your computer and use it in GitHub Desktop.
/* Add to header.php */
<script type="text/javascript" src="<?php bloginfo("template_url"); ?>/js/sidebar_tabs.js"></script>
/* Stored in inc or includes folder as tab-nav.php */
<div id="organic-tabs">
<ul id="tab-nav">
<li id="ex-tab1"><a rel="tab1" href="#" class="current">Featured</a></li>
<li id="ex-tab2"><a rel="tab2" href="#">Categories</a></li>
<li id="ex-tab3"><a rel="tab3" href="#">Bookmarks</a></li>
<li id="ex-tab4" class="last"><a rel="tab4" href="#">Meta</a></li>
</ul>
<div class="clear"></div>
<div id="all-list-wrap">
<ul id="tab1">
<?php echo popularPosts(10); ?>
</ul>
<ul id="tab2">
<?php wp_list_categories('orderby=name'); ?>
</ul>
<ul id="tab3">
<?php wp_list_bookmarks(); ?>
</ul>
<ul id="tab4">
<?php wp_register(); ?>
<li><?php wp_loginout(); ?></li>
<li><a href="http://wordpress.org/" title="Powered by WordPress, state-of-the-art semantic personal publishing platform.">WordPress</a></li>
<?php wp_meta(); ?>
</ul>
</div> <!-- END List Wrap -->
</div> <!-- END Organic Tabs -->
/* Add to fuctions.php */
// Popular posts function
function popularPosts($num) {
global $wpdb;
$posts = $wpdb->get_results("SELECT comment_count, ID, post_title FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , $num");
foreach ($posts as $post) {
setup_postdata($post);
$id = $post->ID;
$title = $post->post_title;
$count = $post->comment_count;
if ($count != 0) {
$popular .= '<li>';
$popular .= '<a href="' . get_permalink($id) . '" title="' . $title . '">' . $title . '</a> ';
$popular .= '</li>';
}
}
return $popular;
}
/* Add to CSS */////////////////////
ul { list-style: none; }
#all-list-wrap ul li a { display: block; border-bottom: 1px solid #666; padding: 4px; color: #666; }
#all-list-wrap ul li a:hover { background: #fe4902; color: white; }
#all-list-wrap ul li:last-child a { border: none; }
#all-list-wrap ul li ul li { border-bottom: 1px solid #666; }
#all-list-wrap ul li ul li:last-child { border: none; }
#organic-tabs { background: #eee; padding: 10px; margin: 0 0 15px 0; -moz-box-shadow: 0 0 5px #666; -webkit-box-shadow: 0 0 5px #666; }
#tab-nav { overflow: hidden; margin: 0 0 10px 0; }
#tab-nav li { width: 65px; float: left; margin: 0 0 0 0; }
#tab-nav li.last { margin-right: 0; }
#tab-nav li a { display: block; padding: 5px; background: #959290; color: white; font-size: 10px; text-align: center; border: 0; }
#tab-nav li a:hover { background-color: #111; }
#tab3, #tab2, #tab4 { display: none; }
#tab-nav li#ex-tab1 a.current, ul#tab1 li a:hover { background-color: #0575f4; color: white; }
#tab-nav li#ex-tab2 a.current, ul#tab2 li a:hover { background-color: #d30000; color: white; }
#tab-nav li#ex-tab3 a.current, ul#tab3 li a:hover { background-color: #8d01b0; color: white; }
#tab-nav li#ex-tab4 a.current, ul#tab4 li a:hover { background-color: #FE4902; color: white; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment