Notes
The display functionality requires the jQuery library and a specific jQuery script file to be loaded, which is performed within the functions.php
file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | /* * Must do this before the ‘get_header’ function is called */ add_action( ‘wp_head’, ‘avp_recent_index_header’ ); function avp_recent_index_header() { if ( is_page_template( ‘recent-index.php’ ) ) { wp_register_style( ‘recent-index-css’, ( get_stylesheet_directory_uri() . ‘/recent-index.css’ ) ); wp_enqueue_style( ‘recent-index-css’ ); wp_register_script( ‘recent-index-jquery’, ( get_stylesheet_directory_uri() . ‘/recent-index.js’ ) ); wp_enqueue_script( ‘recent-index-jquery’, array( ‘jquery’ ) ); wp_enqueue_script( ‘jquery’ ); } } |
This function call defines and queues the requisite jQuery and CSS files to be loaded under the control of the WordPress background processing.
The jQuery function is quite simple: it maps the jQuery function to the year and month links and toggles the displays of the indicator characters and the descendant text blocks when the link is clicked. (Individual date listings do not have links and are always shown underneath the month link when toggled.) Entries for the current year and month are shown by default, other months are hidden by default.
1 2 3 4 5 6 7 8 | jQuery(document).ready( function($) { jQuery( ‘a.list-toggle’ ).click( function() { jQuery(this).children(‘span’).toggle(); jQuery(this).next(‘div’).toggle(); }); }); |
The CSS definitions are used to further emphasize the indicator characters.
1 2 3 4 5 6 7 8 | @charset “utf‑8”; /* CSS Document */ .sitemap-index-span { color: black !important; font-family: monospace; font-size: large; } |
Personal Links