Forums

Query_Posts Question (2 posts)

  1. JSauce16
    Member
    Posted 1 year ago #

    I use the below query on my category template. I would like to use something similar on my tags template. How would I modify this to get posts from a particular tag?

    I assume it has to do with changing 'cat' to something else...

    <?php
    	query_posts(array(
              'cat' => get_query_var('cat'),
    	  'post_type' => array( 'post', 'premier' ),
    	  'order' => 'ASC',
              'orderby' => 'title',
              'posts_per_page' => -1,
  2. jennamolby
    Member
    Posted 1 year ago #

    This is what I use. Slightly different than what you posted:

    <?php
    $args=array(
    'category' => 'CAT',
    'post_type' => array( 'post', 'premier' ),
    'post_status' => 'publish',
    'posts_per_page' => -1,
    'caller_get_posts'=> 1
    );
    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
    while ($my_query->have_posts()) : $my_query->the_post(); ?>

    Where 'Cat' = the category Name.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.