WordPress.org

Ready to get started?Download WordPress

Forums

Taxonomy Images
Add image via API (5 posts)

  1. isay
    Member
    Posted 2 years ago #

    First: Great plugin!

    I sometimes create taxonomies via API calls. Is it possible to add a taxonomy image with code rather than via backoffice UI?

    Cheers,
    Mikael

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

  2. Michael Fields
    Themer
    Plugin Author

    Posted 2 years ago #

    Hello and thank you!

    This is not something that I plan on adding to the plugin, but it is definitely possible. All term/image association are stored under taxonomy_image_plugin in the options table. This is a flat array. The keys represent the term_taxonomy_id and the value represents the ID of an image. Feel free to man-handle this array as much as you like :)

  3. isay
    Member
    Posted 2 years ago #

    Aha, great!
    ...and the image ID corresponds to the ID in the posts table. So to get the url of the image I execute:

    SELECT  ID, guid
    FROM  wp_posts
    WHERE  ID =  '14536'
    AND  post_type =  'attachment'

    Ok, I will play around with this.

    Thanks!
    /Mike

  4. Michael Fields
    Themer
    Plugin Author

    Posted 2 years ago #

    You can never trust the value of guid!

    There should be no need to query the database directly to return posts. Please look into using the get_posts() function.

    To return the relationships, you can use something like:

    $associations = get_option( 'term_taxonomy_id' );
  5. isay
    Member
    Posted 2 years ago #

    Ok, the following worked to get the image:

    $images = get_option('taxonomy_image_plugin');
    echo wp_get_attachment_image( $images[$tax_term_id], 'medium' );

    Now I'm gonna figure out a way to update the image in a similar way...

    //Mike

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic