Forums

[resolved] using of get_the_tags function (4 posts)

  1. giglio
    Member
    Posted 1 year ago #

    How to define some condition to get_tag_link() i.e.
    i would like to show link about a Tag ID concerning only posts not page.
    At the moment using following code:

    i have a list of both posts and pages with tag ID=6.

    Thanks

  2. giglio
    Member
    Posted 1 year ago #

    ops...here the code

    <ul> <li style="list-style-type:circle!important;">
    <a href="<?php echo get_tag_link(6); ?>">Lista di Articoli con contenuti relativi al Genoa</a>
    </li>
    </ul>
  3. MichaelH
    Volunteer
    Posted 1 year ago #

    <?php
    $args=array(
      'tag__in' => array(6),
      'post_type' => 'post',
      '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() ) {
      echo 'List of Posts for tag id 6';
      while ($my_query->have_posts()) : $my_query->the_post(); ?>
        <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
        <?php
      endwhile;
    }
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?>
  4. giglio
    Member
    Posted 1 year ago #

    Hi Michael,
    i justuo upload your code.

    Thank yoy very much.

    Best Regards

    g.

Topic Closed

This topic has been closed to new replies.

About this Topic