• Resolved harshclimate

    (@harshclimate)


    I’m not sure what I’m doing wrong, but I’m willing to bet it’s a simple fix. I have a few custom post types, one called Arizona Wine and one called Arizona Beer. In each CPT I use the built in tags/category meta boxes. I’m only using the tag one. So for each CPT I use the tag field to list a city like “Tucson”.

    In tag.php I’ve set up a new wp query and added <?php single_tag_title(); ?> at the top of the page to test whether or not the page works and it does. The page shows the “Tucson” tag title. Now, I built the query like so:

    $args = array(
            'posts_per_page' => -1,
            'tag'            => get_queried_object(),
            'post_status'    => 'publish',
            'orderby'        => 'DESC',
            'order'          => 'title'
    
     ); $tag_query = new WP_Query( $args );

    All I get on my page is the else statement “Posts under that tag are not found”.

    I’m not sure why posts aren’t being shown. Anyone out there know what might be going on?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The query is for posts, not custom post types.

    Thread Starter harshclimate

    (@harshclimate)

    On that note, I did see a few errors in my query. I changed the above to:

    $args = array(
             'posts_per_page' => -1,
             'post_type'      => array( 'arizonawine', 'arizonabeer', 'spotlight', 'posts' ),
             'tag'            => get_queried_object(),
             'post_status'    => 'publish',
             'orderby'        => 'title',
             'order'          => 'ASC'
    
    ); $tag_query = new WP_Query( $args );

    Still no success.

    Thread Starter harshclimate

    (@harshclimate)

    Okay, I got it working. I had to add a little something to the query:

    at 'tag' => get_queried_object() I added 'tag' => get_queried_object()->slug and now everything seems to be showing up. Sorry for the confusion!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Tag.php not showing respective tagged posts’ is closed to new replies.