• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Tag Blunder

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › General Discussion › Tag Blunder

This topic is: resolved

Tagged: archives, tag, tags

  • This topic has 2 replies, 1 voice, and was last updated 13 years, 5 months ago by vajrasar.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • February 17, 2013 at 6:12 am #20786
    vajrasar
    Member

    Am using a custom template (tag.php) to show posts related to tag. So when someone clicks on say tag 'A' then he/she gets redirected to my tag.php layout instead of genesis's default template for archives. I did this by making a tag.pho in my child theme.
    Now the problem is some of my posts are marked with multiple tags. for example -
    Tag 'A' - 15 posts
    Tag 'B' - 5 posts
    Tag 'A' & 'B' - 20 posts.

    Now when someone clicks on Tag 'A' from sidebar tag list, then it gets the list of 15 posts which is right. But when someone clicks on Tag 'B' then also the user gets the list of same 15 posts.

    The problem do not ends here, am also using 'paged' option, so when user (while seing Tag 'A' posts) clicks on next page, then it is shown as blank. But when user sees posts of Tag 'B' then also there is pagination visible (but it should not be because there are only 5 posts) and when user clicks next page, then it shows 404 error.

    Here is the code am using - [I have also pasted code in patebin for better view - http://pastebin.com/kjNYkYzV %5D

    <?php

    function uttt_custom_loop()
    {
    global $post;
    $tags = wp_get_post_tags($post->ID);
    $first_tag = $tags[0]->term_id;
    // arguments, adjust as needed
    $args = array(
    'post_type' => 'post',
    'tag__in' => array($first_tag),
    'post_status' => 'publish',
    'paged' => get_query_var( 'paged' )
    );

    global $wp_query;
    $wp_query = new WP_Query( $args );
    $cnt=1;
    if ( have_posts() ) : while ( have_posts() ) : the_post();
    ?>
    <div id="post_page_grid" style="<?php echo (isset($cnt) && $cnt==7)?'clear:both':'';?>">
    <?php $link_to_pic = post_custom('restro-pic'); ?>
    <div id="img_ra">
    <div id="img_div_custom">
    <?php
    if ($link_to_pic !='')
    { ?>
    <img src="<?php echo $link_to_pic; ?>" alt="restaurant-pic"/>
    <?php
    }
    else if ($link_to_pic =='')
    { ?>
    <img src="<image-path>"/> <?php
    } ?>
    </div>
    <div id="rating_custom">
    <?php echo do_shortcode('[starrater tpl=10 read_only=1]'); ?>
    </div>
    </div>
    <div id="post_page_cont">
    <b><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></b>
    <?php the_excerpt(); ?>
    </div>

    </div>
    <?php
    $cnt=$cnt+1;
    endwhile;
    do_action( 'genesis_after_endwhile' );
    endif;
    wp_reset_postdata();
    }
    remove_action( 'genesis_loop', 'genesis_do_loop' );
    add_action( 'genesis_loop', 'uttt_custom_loop' );

    genesis();

     

    So what am I doing wrong. Thanks for any help that you can provide.


    I make WordPress websites using Genesis Framework.

    WordPress/Genesis Development | Customizations

    February 17, 2013 at 6:21 am #20788
    vajrasar
    Member

    Pastebin seems not to be working so here is another link of the code - http://codepad.org/l8oH7zCz


    I make WordPress websites using Genesis Framework.

    WordPress/Genesis Development | Customizations

    February 17, 2013 at 7:40 am #20797
    vajrasar
    Member

    Ok so I sorted the issue for now by using -

     

    $queried_object = get_queried_object();
    $term_id = $queried_object->term_id;

     

    instead of -

    $tags = wp_get_post_tags($post->ID);
    $first_tag = $tags[0]->term_id;

     


    I make WordPress websites using Genesis Framework.

    WordPress/Genesis Development | Customizations

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Tag Blunder’ is closed to new replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble