Taxonomy Images

Community Forums Forums Design Tips and Tricks Taxonomy Images

This topic is: not resolved

This topic contains 6 replies, has 2 voices, and was last updated by  Au Coeur 1 year, 7 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #12445

    Au Coeur
    Participant
    Post count: 102

    (The site is http://www.nantucket-bucket.com/, but it has a maintenance screen up so you can’t see it…)

    I am using the Taxonomy Images plug-in to associate images with a custom taxonomy and was wondering if someone can help me with getting the images to appear in the meta section below each post.

    I am using the following code to display my custom taxonomies:

    /** Customize the post meta function */
    add_filter( ‘genesis_post_meta’, ‘post_meta_filter’ );
    function post_meta_filter($post_meta) {
    if ( !is_page() ) {
    $post_meta = ‘ [post_terms before="Bucket Rating: " taxonomy="rating"] [post_terms before="Price: " taxonomy="price"] [post_terms before="Open/Available: " taxonomy="open-dates"] <br/>[post_terms before="Ages: " taxonomy="ages"] <br/> [post_categories before="Filed Under: "] [post_tags before="Tagged: "]‘;
    return $post_meta;
    }}

    The plugin uses

    print apply_filters( 'taxonomy-images-list-the-terms', '' );

    to return all the images and provides this example of how to call the images rather than taxonomy name:

    $terms = apply_filters( 'taxonomy-images-get-terms', '' );
    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>';
    }

    Anyone have any idea how I would integrate this with the genesis customize meta code?



    Mother. Web & Graphic Designer. Lactation Consultant. Blogging about how it all fits together, most recently from northern Colorado. Visit my blog or my design site.

    #12671

    cdils
    Participant
    Post count: 421

    You can use wp_get_attachment_image to grab the image associated with your taxonomy. It might look like this:

    wp_get_attachment_image( $term->image_id, ‘thumbnail’ )

    So, incorporated into your $post_meta it would work like this:

    $post_meta = ‘[post_terms before="Bucket Rating: " taxonomy="rating"]‘ . wp_get_attachment_image( $term->image_id, ‘thumbnail’ ) . ‘more stuff’;

    Note that $terms is the name of a particular taxonomy. You can set that variable dynamically if you’re looping through multiple taxonomies or hardcode it.

    Experiment with it and let me know if that sets you in the right direction.

    Cheers,
    carrie


    Have you been helped in this forum? Pay it forward and answer someone else’s question. I bet you’ll know the answer to at least one question. :)

    I host a weekly Genesis-focused podcast called Genesis Office Hours. I tweet @cdils.

    #12806

    Au Coeur
    Participant
    Post count: 102

    I don’t know…I am not having any luck with this at all.  When I try inserting wp_get_attachment_image into the $post_meta, it just outputs as text.


    Mother. Web & Graphic Designer. Lactation Consultant. Blogging about how it all fits together, most recently from northern Colorado. Visit my blog or my design site.

    #12835

    cdils
    Participant
    Post count: 421

    When you say wp_get_attachment_image is outputting text, is it literally printing wp_get_attachment_image to the screen? If so, you might have accidentally put it in quotes so that it’s being parsed as text and not PHP.

    Can you paste the exact code you’re using?

    Cheers,

    Carrie


    Have you been helped in this forum? Pay it forward and answer someone else’s question. I bet you’ll know the answer to at least one question. :)

    I host a weekly Genesis-focused podcast called Genesis Office Hours. I tweet @cdils.

    #13132

    Au Coeur
    Participant
    Post count: 102

    Yes, that is what I mean.  I tried a few different things with the code to see if I was misunderstanding and that is all it seems to do. This is what is currently being used:
    /** Customize the post meta function */
    add_filter( 'genesis_post_meta', 'post_meta_filter' );
    function post_meta_filter($post_meta) {
    if ( is_single() ) {
    $post_meta = ' wp_get_attachment_image( $term->224, ‘full’ )
    [post_terms before="Price: " taxonomy="price"] [post_terms before="Open/Available: " taxonomy="open-dates"] [post_terms before="Ages: " taxonomy="ages"]';
    return $post_meta;
    }
    if ( is_category() ) {
    $post_meta = '[post_terms before="Price: " taxonomy="price"][post_terms before="Ages: " taxonomy="ages"][post_terms before="Open/Available: " taxonomy="open-dates"] ';
    return $post_meta;
    }
    }


    Mother. Web & Graphic Designer. Lactation Consultant. Blogging about how it all fits together, most recently from northern Colorado. Visit my blog or my design site.

    #13287

    cdils
    Participant
    Post count: 421

    This line needs to be corrected from

    $post_meta = ' wp_get_attachment_image( $term->224, ‘full’ ) [post_terms before="Price: " taxonomy="price"]

    to

    $post_meta = wp_get_attachment_image( $term->224, ‘full’ ) . '[post_terms before="Price: " taxonomy="price"]

    Including it within the single quote was telling it is was text as opposed to code to execute. :)


    Have you been helped in this forum? Pay it forward and answer someone else’s question. I bet you’ll know the answer to at least one question. :)

    I host a weekly Genesis-focused podcast called Genesis Office Hours. I tweet @cdils.

    #13400

    Au Coeur
    Participant
    Post count: 102

    I couldn’t get it to work with wp_get_attachment_image, but I realized I didn’t actually need it to output in $post_meta, so long as it just appeared to be in the same section. So, I just added it another way. On the off chance that someone else is looking for how to make this work, here is what I did.

    add_action('genesis_before_post_content', 'child_bucket_rating');
    function child_bucket_rating() {
    if( is_single() ) {
    print apply_filters( 'taxonomy-images-list-the-terms', '', array(
    'after' => '',
    'after_image' => '',
    'before' => 'Nantucket Bucket Rating:',
    'before_image' => '',
    'image_size' => 'full',
    'taxonomy' => 'rating',
    ) );
    }}

    Thanks for the help cdils


    Mother. Web & Graphic Designer. Lactation Consultant. Blogging about how it all fits together, most recently from northern Colorado. Visit my blog or my design site.

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.