‘get_recent_posts’ Not Working for Custom Post Type
-
Hello!
I’m having difficulties to get a custom query work with get_recent_posts and a cusotm post type. I want the function to call the most recent post within the “podcasts” CPT, but for some reason the query isn’t working.
Any help I canget would be greatly appreciated!
Here’s my code:
<?php $args = array( 'numberposts' => 1, 'offset' => 0, 'category' => 0, 'orderby' => 'post_date', 'order' => 'DESC', 'include' => '', 'exclude' => '', 'meta_key' => '', 'meta_value' =>'', 'post_type' => 'podcasts', 'post_status' => 'publish', 'suppress_filters' => true ); $recent_posts = wp_get_recent_posts( $args ); ?> <ul id="podcastbox-wrap"> <?php $recent_posts = wp_get_recent_posts(); foreach( $recent_posts as $recent ){ echo '<li id="podcastlist"><a id="podcast-link" style="background-color:#8617ce;" href="' . get_permalink($recent["ID"]) . '">Latest Podcast Episode</a> <img id="podcastbox-image" src="'.get_the_post_thumbnail($recent["ID"], 'large').'"></li> '; } wp_reset_query(); ?>
thanks!!!
The page I need help with: [log in to see the link]
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘‘get_recent_posts’ Not Working for Custom Post Type’ is closed to new replies.