WordPress.org

Ready to get started?Download WordPress

Forums

Taxonomy Images II
Something i did for listing out arrays of terms with images (1 post)

  1. latro666
    Member
    Posted 1 year ago #

    Not sure how useful this will be for folks and its pretty hacky and probably inefficient, you never know though it might come in handy.

    I basically wanted to have this cool plugin be able to output (anywhere) the normal get_terms WP call but have the images added in.

    Put this code in my functions.php

    http://pastebin.com/qw7zyyBG

    So in the theme call something like:
    get_terms_with_category_images_ii('equipmenttypes')

    Will give an array like this:

    Array
    (
        [1] => stdClass Object
            (
                [term_id] => 261
                [name] => Grass cutting
                [slug] => grass-cutting
                [term_group] => 0
                [term_taxonomy_id] => 133
                [taxonomy] => equipmenttypes
                [description] =>
                [parent] => 0
                [count] => 1
                [img] => yourdomain/wp-content/uploads/category-images-ii/261.original.jpg
                [tmb] => yourdomain/wp-content/uploads/category-images-ii/261.thumb.jpg
            )

    Same as the normal get_terms but with:
    [img] => yourdomain/wp-content/uploads/category-images-ii/261.original.jpg
    [tmb] => yourdomain/wp-content/uploads/category-images-ii/261.thumb.jpg

    Might wanna change ln21 to '$terms = get_terms($tax,'hide_empty=0');' if you want to use this to show a panel of consistent options.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic