Support » Plugin: Multi-column Tag Map » How to link tag in list to a specific post

  • Resolved blogdropper

    (@blogdropper)


    Hi, I’m using mctagmap to list taxonomies. Each taxonomy appears in a single post, how can I redirect the link to the post the taxonomy appears on?

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author tugbucket

    (@tugbucket)

    Sorry for the delay. Both your topics are essentially the same. By default a tag link will direct to the archive for the tag. If you are ever only going to have 1 unique tag for each post or rather each tag used only belongs to a single post, then the tag link default isn’t going to work. You’re better off rolling your own solution.

    You can try to work in this:

    <?php
    $tag = 'apple';
    $the_query = new WP_Query( 'tag='.$tag);
    
    if ( $the_query->have_posts() ) {
        echo '<ul>';
        while ( $the_query->have_posts() ) {
            $the_query->the_post();
            echo '<li><a href="' . get_the_permalink() . '">'.$tag.'</a></li>';
        }
        echo '</ul>';
    } else {
        // no posts found
    }
    wp_reset_postdata()
    ?>
    Thread Starter blogdropper

    (@blogdropper)

    Hi,
    Thanks for getting back to me.
    I have Toolset, contacted their support and they came up with this solution:

    
    

    function redirect_my_custom_tax_archive_to_post() {
    if (is_tax(‘english-name’)) {
    global $post;
    wp_safe_redirect(get_permalink($post->ID));
    die;
    }
    }
    add_action(‘template_redirect’,’redirect_my_custom_tax_archive_to_post’);`
    `
    Works great!

    Plugin Author tugbucket

    (@tugbucket)

    @blogdropper oh that’s nifty. Going to save that one.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to link tag in list to a specific post’ is closed to new replies.