WordPress has a global object variable $wpdb, which communicates with the WordPress database. We can read more about $wpdb in Codex.
Views: 39
WordPress has a global object variable $wpdb, which communicates with the WordPress database. We can read more about $wpdb in Codex.
Views: 39
For listing the published year of the particular post type, we can use the SQL as presented below.
<ul id="termsYear"> <?php $years = $wpdb->get_results( "SELECT YEAR(post_date) AS year FROM wp_posts WHERE post_type = 'media' AND post_status = 'publish' GROUP BY year DESC" ); foreach ( $years as $year ) {?> <li><a data-val='<?=$year->year?>' class="year"><?=$year->year?></a></li> <?php } ?>
Replace the ‘post_type’ with your own post type.
Views: 22