WordPress.org

Forums

Dynamically Pull Custom Post (2 posts)

  1. htausch
    Member
    Posted 11 months ago #

    How do I replace pulling a post with a certain category to pulling a custom post type with a certain category. I want to leave the ability to determine the number of posts shown by using the theme's widget.

    This is the code I think I need to fiddle with.

    $query = new WP_Query( array( 'cat' =>$slidecat,'posts_per_page' =>$count ) );
    		           	if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post();	?>
  2. justclint
    Member
    Posted 11 months ago #

    You will want to use 'post_type' in the argument, so using the code above and with a custom post type called 'music' for example, you would do something like:

    $query = new WP_Query( array( 'post_type' => 'music', 'cat' =>$slidecat,'posts_per_page' =>$count ) );
    if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post(); ?>

    For more info see the args for WP_Query: http://codex.wordpress.org/Class_Reference/WP_Query

Reply

You must log in to post.

About this Topic