Community Forums › Forums › Archived Forums › Design Tips and Tricks › Taxonomy Images
- This topic has 6 replies, 2 voices, and was last updated 12 years, 2 months ago by
Au Coeur.
-
AuthorPosts
-
January 16, 2013 at 4:08 pm #12445
Au Coeur
Member(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.
January 17, 2013 at 12:31 pm #12671cdils
ParticipantYou 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 WordPress-focused podcast called Office Hours. I tweet @cdils.
January 18, 2013 at 12:16 am #12806Au Coeur
MemberI 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.
January 18, 2013 at 7:35 am #12835cdils
ParticipantWhen 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 WordPress-focused podcast called Office Hours. I tweet @cdils.
January 19, 2013 at 1:52 pm #13132Au Coeur
MemberYes, 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.
January 20, 2013 at 11:06 am #13287cdils
ParticipantThis 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 WordPress-focused podcast called Office Hours. I tweet @cdils.
January 20, 2013 at 9:10 pm #13400Au Coeur
MemberI 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.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.