• This is probably more of a request, but is also a “how to”. As I create a Post, I use Tags. Most of my Tags are names of people–basketball players. So when a User clicks on that Tag, the User is taken to a page with every Post written about that player linked.

    I’ve looked for a plugin that would echo database information to that Tag’s page. I don’t gather there is one, but I’m betting it could be done. I’m limited in my PHP knowledge.

Viewing 3 replies - 1 through 3 (of 3 total)
  • See Tag Templates for starters.

    Thread Starter Jim R

    (@jim-r)

    I want to take the $tag_id and associate it with information in another table. Keep in mind, at this stage, I’m manually copying the $tag_id from my WordPress table to my custom table. Again, in my custom table, it’s about a player (his name, school, grade, height, etc), while my Tags in WP are player names, school names, class (2010, 2011, etc) and other keywords. That means not all my $tag_id are useful to me in my custom table.

    So let’s go back to the User clicking on a Tag link. It passes the User to the Archive.php page template with the URL of https://www.hoosierhoopsreport.com/tags/firstWord_secondWord. The actual ID isn’t passed via the URL. Is it still there for me to use?

    This will get you you the tag id and more if used in an archive.php or tag.php template in your theme

    <?php
    $term_id='';
      if ( is_tag() ) {
        $term_id = get_query_var('tag_id');
        $taxonomy = 'post_tag';
        $title = 'Tag: ';
      }
      if ( is_category() ) {
        $term_id = get_query_var('cat');
        $taxonomy = 'category';
        $title = 'Category: ';
      }
    if ($term_id) {
      $args ='include=' . $term_id;
      $terms = get_terms( $taxonomy, $args );
      if ($terms) {
        foreach($terms as $term) {
          if ($term->count > 0) {
            echo '<p>' . $title . '<a href="' . get_term_link( $term->term_id, $taxonomy ) . '" title="' . sprintf( __( "View all posts in %s" ), $term->name ) . '" ' . '>' . $term->name.'</a> has ' . $term->count . ' post(s). </p> ';
          }
        }
      }
    }
    ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Linking profile or database information to Post Tags…’ is closed to new replies.