Get singular post using get_posts
-
Hi,
Has anyone had any joy getting the latest download post using the get_posts WordPress function? I have tried getting a single post using this, as below, but have had no joy:
<?php $args = array( ‘posts_per_page’ => 1, ‘category’ => 2, ‘post_type’ => ‘dlm_download’);
$myposts = get_posts( $args );
foreach ( $myposts as $post ) : setup_postdata( $post ); ?>
“><?php the_title(); ?>
<?php endforeach; ?>The category ID for my post category is 2, and this category has 30 posts, so I should be getting a post returned. If anyone could shed any light that would be great.
Thanks.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Get singular post using get_posts’ is closed to new replies.