SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2011
    Location
    Vancouver, BC
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Display image tags???

    Hey guys,

    I'm trying to display the tags that have been added to an image. I find it easy enough to display the alternate text and imageURL but I can't seem to echo out the image tags. I can't even see the tag property within the image object. Thanks for the help.

    PHP Code:

    $ad_image = nggdb::find_image($image_id);

    if($ad_image) :
                $external_link = nggcf_get_field($ad_image->pid, 'External Link');
                ?>
            <a href="<?php echo isset($external_link) ? $external_link '#'?>">
                <img src="<?php echo $ad_image->imageURL?>" alt="<?php echo $ad_image->alttext?>">
            </a>
            
            <?php $posttags get_the_tags();
    if (
    $posttags) {
    foreach(
    $posttags as $tag) {
    echo 
    $tag->name ' ';
    }
    }

  2. #2
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,938
    Mentioned
    214 Post(s)
    Tagged
    12 Thread(s)
    Hi ConTici,

    The following code should do what you want.

    HTH

    Code PHP:
    <?php $tags = wp_get_object_terms($image->pid,'ngg_tag') ?>
     
    <?php foreach ( $tags as $tag ) : ?>
      <?php echo $tag->name; ?>
    <?php endforeach; ?>

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2011
    Location
    Vancouver, BC
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Pullo, I'll give it a try.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •