Title: Get singular post using get_posts
Last modified: August 21, 2016

---

# Get singular post using get_posts

 *  [aboother](https://wordpress.org/support/users/aboother/)
 * (@aboother)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/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.
 * [http://wordpress.org/plugins/download-monitor/](http://wordpress.org/plugins/download-monitor/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [bravenewniche](https://wordpress.org/support/users/bravenewniche/)
 * (@bravenewniche)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/get-singular-post-using-get_posts/#post-4302005)
 * DLM uses a custom taxonomy, while your array references the default “category”
   for posts.
 * So instead of ‘category’ => 2
 * Try ‘dlm_download_category’ => ‘name-of-category’
 *  Thread Starter [aboother](https://wordpress.org/support/users/aboother/)
 * (@aboother)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/get-singular-post-using-get_posts/#post-4302006)
 * Great, worked a treat.
 * Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Get singular post using get_posts’ is closed to new replies.

 * ![](https://ps.w.org/download-monitor/assets/icon-256x256.png?rev=3198936)
 * [Download Monitor](https://wordpress.org/plugins/download-monitor/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/download-monitor/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/download-monitor/)
 * [Active Topics](https://wordpress.org/support/plugin/download-monitor/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/download-monitor/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/download-monitor/reviews/)

## Tags

 * [get_posts](https://wordpress.org/support/topic-tag/get_posts/)

 * 2 replies
 * 2 participants
 * Last reply from: [aboother](https://wordpress.org/support/users/aboother/)
 * Last activity: [12 years, 5 months ago](https://wordpress.org/support/topic/get-singular-post-using-get_posts/#post-4302006)
 * Status: not resolved