Forums

[Plugin: Taxonomy Images BETA] Images and link in post (5 posts)

  1. M4Z1NH0
    Member
    Posted 2 years ago #

    I need help, I'm wanting to add the tags in the post with the image that I use on Taxonomy Images BETA, with this code can be used with images uploaded and just get the tags post_tag.

    Can anyone help me get it to work?

    <?php
    $posttags = get_the_tags();

    if ($posttags) {
    foreach($posttags as $tag) {
    echo 'term_id).'" /><img src="http://www.mysite.com/wp-content/uploads/' . $tag->name . '.jpg"
    alt="' . $tag->name . '" />
    ';
    }
    }
    ?>

    Another question how to get that search tags'll meet a taxonomy created by me?

    Thank you.

    http://wordpress.org/extend/plugins/taxonomy-images/

  2. Michael Fields
    Theme Wrangler
    Posted 2 years ago #

    The following code should produce the results you are looking for:

    $post_tags = get_the_tags();
    if ( $post_tags ) {
    	foreach( $post_tags as $t ) {
    		$url = get_term_link( $t->name, $t->taxonomy );
    		$img = $taxonomy_images_plugin->get_image_html( 'detail', $t->term_taxonomy_id );
    		if( !empty( $img ) )
    			print '<a title="' . $t->name . '" href="' . $url . '">' . $img . '</a>';
    	}
    }

    Best wishes,
    -Mike

  3. M4Z1NH0
    Member
    Posted 2 years ago #

    Thanks mfields

    It worked, I would like to know how to display images of custom_taxonomies, I created two, actor and website, where I have to edit the images appear to show the images of these custom_taxonomies?

    Thank you for your help.

  4. Michael Fields
    Theme Wrangler
    Posted 2 years ago #

    This code will display a list of all terms of a given taxonomy that have images associated to them via the plugin. Please change the second argument of get_the_terms() to the value of the slug of your custom taxonomy.

    $terms = get_the_terms( $post->ID, 'my-custom-taxonomy-slug' );
    if ( $terms ) {
    	foreach( $terms as $t ) {
    		$url = get_term_link( $t->name, $t->taxonomy );
    		$img = $taxonomy_images_plugin->get_image_html( 'detail', $t->term_taxonomy_id );
    		if( !empty( $img ) )
    			print '<a title="' . $t->name . '" href="' . $url . '">' . $img . '</a>';
    	}
    }
  5. M4Z1NH0
    Member
    Posted 2 years ago #

    Thank mfields gave correctly, perfect.

    Longer had a code that tried to edit most failed, it can also help would be very grateful.

    <?php
    $backup = $post;
    $tags = wp_get_post_tags($post->ID);
    if ($tags) {
    $tag_ids = array();
    foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
    $args=array(
    'tag__in' => $tag_ids,
    'post__not_in' => array($post->ID),
    'showposts'=>9, // Number of related posts that will be shown.
    'caller_get_posts'=>1
    );
    $my_query = new wp_query($args);
    if( $my_query->have_posts() ) {
    echo '<h3>Outros Vídeos</h3>

    ';
    }
    }
    $post = $backup;
    wp_reset_query();
    ?>

    It shows post related statement based on tags, I think custom taxonomy would be best for my use.

    Again thank you for your help.

Topic Closed

This topic has been closed to new replies.

About this Topic