Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Simple sliding archive for wordpress

Featured Replies

Ok, So I found an example of a simple slider function that displays a list of blog archives by year, when clicked it slides down to show the months of that year. Great! Only problem is that clicking again should hide it, but it doesn't. Any ideas what I am missing? Code below.

 

<script type="text/javascript">
$(document).ready(function() {

$('.blog-list-archive li ul').hide();
$('.blog-list-archive li a').click(function(){
 $(this).parent().addClass('selected');
 $(this).parent().children('ul').slideDown(250);
 $(this).parent().siblings().children('ul').slideUp(250);
 $(this).parent().siblings().removeClass('selected');
});
});
</script>
<style>
.archive-sub-menu {
display:none;
}
</style>
<div class="blog-list-archive">

 <?php
    /**/
    $years = $wpdb->get_col("SELECT DISTINCT YEAR(post_date) FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY post_date DESC");
    foreach($years as $year) :
    ?>
	    <li><a class="title" href="Javascript:void()"><?php echo $year; ?></a>

		    <ul class="archive-sub-menu">
		    <? $months = $wpdb->get_col("SELECT DISTINCT MONTH(post_date) FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' AND YEAR(post_date) = '".$year."' ORDER BY post_date  DESC");
			    foreach($months as $month) :
			    ?>
			    <li><a href="<?php echo get_month_link($year, $month); ?>"><?php echo date( 'F', mktime(0, 0, 0, $month) );?></a>
			    </li>
			    <?php endforeach;?>
		    </ul>
	    </li>
    <?php endforeach; ?>

</div>

  • Author

Ok, so after changing the date on a few posts to last year (to bring up a secondary year level) it is actually working lol. However, could this be modified so somehow you can view the archive by year as well, not just have the year selector open the dropdown? Make sense?

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.