I am working on a custom Wordpress template for the archive. I have the archive set up by category but now I want to organize by category and month but I can't figure out how to access the month argument from the permalink. How would I get access to that argument.

migrated from stackoverflow.com Oct 10 '12 at 3:41

This question came from our site for professional and enthusiast programmers.


the standard WP function for that is:



  • I don't need it for the post itself. I tried using <?php query_posts( array ( 'category_name' => 'shop', 'posts_per_page' => 33,"monthnum"=> $_GET['month'] ) );?> to get only the post of the month found in the url to the post: "2012/10/?cat=1" – Markus M. Gray Oct 9 '12 at 17:36
  • You don't need to use that on the post itself (e.g. 'single.php'). If you use it in your archive template, it should push out the date it was published (provided you're running a proper loop...). very similar to <?php printf(get_post_meta($post->ID, 'firstname', true); which is a function I use in my ARCHIVE-REP.PHP file in one of my sites which echos the custom field "firstname". if you replace the function with the_date() there's no reason it shouldn't show up. – Alex Demchak Oct 9 '12 at 17:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy