On the post page I want to get all the years in which the records are posted. I use now the wp_get_archives() function. But this function gives what is needed not as it should. I do this: wp_get_archives(array('type' => 'yearly', 'post_type' => 'events')); and I get years in the markup inside the <li> and <a> tags, and I need them as a string or an array to make custom markup. Advise how this can be done!?
|
1 answer
You can take the wp_get_archives function as a wp_get_archives throwing out all unnecessary from it (everything is more or less clear).
Or directly pull the data from MySQL, but this is not the most accurate option.
SELECT YEAR(post_date) AS `year`, count(ID) as posts FROM wp_posts WHERE post_type = 'events' AND post_status = 'publish' GROUP BY YEAR(post_date) ORDER BY post_date; - Here's a separate thank you for the request) And I did, but the links there are in the way. I need to get request via link. - pwnz22
- oneThe request is almost completely copied from the function code
wp_get_archivescore.trac.wordpress.org/browser/tags/4.5.3/src/wp-includes/… - MrClon
|