Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question

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

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

1 Answer 1

up vote 1 down vote accepted

the standard WP function for that is:

the_date();

(source)

share|improve this answer
    
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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.