WordPress.org

Ready to get started?Download WordPress

Forums

Download Monitor
Get singular post using get_posts (3 posts)

  1. aboother
    Member
    Posted 5 months ago #

    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/

  2. bravenewniche
    Member
    Posted 4 months ago #

    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'

  3. aboother
    Member
    Posted 4 months ago #

    Great, worked a treat.

    Thank you.

Reply

You must log in to post.

About this Plugin

About this Topic