WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [Plugin: Taxonomy Images] - Custom taxonomy cloud containing images (8 posts)

  1. Cibulka
    Member
    Posted 2 years ago #

    Hi, quick question about the awesome plugin TAXONOMY IMAGES: http://wordpress.org/extend/plugins/taxonomy-images/

    It basically enables to upload image assigned to a custom taxonomy tag in nice user interface.

    THE QUESTION: Is it possible to list EVERY tag from given taxonomy with its name, description and (of course) the image?

    I'm using the functionality do display sponsors of the project, so besides the text about them I need to display their logo as well.

    Thanks for great plugin and cheers from Prague! C.

  2. Cibulka
    Member
    Posted 2 years ago #

    BTW: I know there is a lot of workarounds (such as use "custom fields" for custom taxonomies: http://en.bainternet.info/2011/custom-taxonomies-extra-fields). Due to a nice user interface of the plugin, I prefer to stick with TAXONOMY IMAGES.

    Thanks!

  3. Michael Fields
    Themer
    Posted 2 years ago #

    When you add the following line to a theme file:

    $terms = apply_filters( 'taxonomy-images-get-terms', '' );

    You will get an array of term objects. You can then loop over each object and print the needed data to the screen. Please see the "Working with all terms of a given taxonomy" section in http://wordpress.org/extend/plugins/taxonomy-images/ for a full list of modifiers that you can use.

    There is another plugin in the works to make this easier, but it is not fully tested yet.

  4. Cibulka
    Member
    Posted 2 years ago #

    Hello Michael, thank you for the quickest reply!

    However I am getting still confused - after following the plugin instructions and using this code inside my "index.php" template -

    <?php
    	$terms = apply_filters( 'taxonomy-images-get-terms', 'sponzori' );
    	if (!empty($terms)) {
    		print '<ul>';
    		foreach( (array) $terms as $term ) {
    		print '<li><a href="' . esc_url( get_term_link( $term, $term->taxonomy ) ) . '">' . wp_get_attachment_image( $term->image_id, 'detail' ) . '</li>';
    	}
    	print '</ul>';
    	} else { echo'nothing'; }
    ?>

    - I am getting "nothing". I am sure that it is obvious what I'm doing wrong but since I am no PHPer, I still do not follow. :) Where should I specify the name or ID of the custonomy I want to retrieve?

    Or is the plugin meant to work just on custom taxonomy archive pages?

    Thank you, C.

  5. Cibulka
    Member
    Posted 2 years ago #

    + "sponzori" is the name of my custom taxonomy

  6. Michael Fields
    Themer
    Posted 2 years ago #

    Maybe something like this (untested):

    <?php
    	$terms = apply_filters( 'taxonomy-images-get-terms', null, array(
    		'taxonomy' => 'sponzori',
    	) );
    	if ( ! empty( $terms ) ) {
    		print '<ul>';
    		foreach( (array) $terms as $term ) {
    			print '<li><a href="' . esc_url( get_term_link( $term, $term->taxonomy ) ) . '">' . wp_get_attachment_image( $term->image_id, 'detail' ) . '</li>';
    		print '</ul>';
    	}
    ?>
  7. Cibulka
    Member
    Posted 2 years ago #

    WORKS!

    I just needed to change two bits:

    <?php
    	$terms = apply_filters( 'taxonomy-images-get-terms', null, array(
    		'taxonomy' => 'sponzori',
    	) );
    	if ( ! empty( $terms ) ) {
    		print '<ul>';
    		foreach( (array) $terms as $term ) {
    			print '<li><a href="' . esc_url( get_term_link( $term, $term->taxonomy ) ) . '">' . wp_get_attachment_image( $term->image_id, 'detail' ) . '</a></li>';
    		} print '</ul>';
    	}
    ?>

    1) 2nd print command: end of anchor tag (</a></li>)
    2) (before) 3rd print command: extra "}".

    Michael, thank you very much!

  8. Michael Fields
    Themer
    Posted 2 years ago #

    Nice! Glad to hear that ... sorry for posting buggy code :)

Topic Closed

This topic has been closed to new replies.

About this Topic