Forum Replies Created
-
AuthorPosts
-
jsperlMembervar_dump($queried_object);returns null so it appears I have more work to do…will take it up with the Views people…I sure hope I can get Piklist and Views to play nice together!
jsperlMemberThanks Steve! So I was on the right track with the `get_queried_object();’ function. I still can’t get it to display anything though, but I’m not sure it’s a Piklist issue. I’m trying to output this in a Toolset Views taxonomy view, and since Views doesn’t allow php directly I have to wrap it in a shortcode first:
function cat_icon() { $queried_object = get_queried_object(); $term_id = $queried_object->term_id; $image_id = get_term_meta( $term_id, 'upload_media' ); $image_url = wp_get_attachment_url($image_id); print $image_url; } add_shortcode( 'caticon', 'cat_icon' );Then I’m trying to add it to my view with
<img src="[caticon]" height="75" width="75" />Which normally should work in Views, but nothing is displayed. In troubleshooting whether my view is taking the shortcode I’ve tried something simple like
function cat_icon() { print "Hola!"; } add_shortcode( 'caticon', 'cat_icon' );And that DOES work when added to my view…which makes me think wrapping it in shortcode is not the problem. I’m also not sure what the best way of outputting $image_url is, print, echo, or return…I’ve tried all 3 to no avail. Anyway, I don’t want to take too much of your time from developing this great product as I’m not even sure it’s a Piklist issue…I’m going to post on the Toolset forum to see I can get any insight there.
jsperlMemberI’ve also tried
$term = get_term( get_queried_object(), 'item-category' ); $term_id = $term->term_id;
jsperlMemberThanks Kevin, but it’s that first step (getting the ID of the term) that I can’t figure out…I’ve read the codex descriptions many times and tried many of the examples but still not getting it. Here are a couple of things I’ve tried the do not work:
$queried_object = get_queried_object(); $term_id = $queried_object->term_id;and
$term = get_term( term_id, 'item-category' ); $term_id = $term->term_id;What I don’t understand is what to put in place of “term_id” in the get_term() function in order to get the current term ID.
Is there any way you could post a snippet of exactly how to do this? My previous post describes the context and what I’m trying to do. Hope it’s clear enough. Thanks!
jsperlMemberSorry to be a pest, but I’m missing something here and am really stuck. My goal is to retrieve the URL of an image from the currently queried taxonomy term. I’ve adde an image field to my custom taxonomy with the following Piklist code:
piklist('field', array( 'type' => 'file' ,'field' => 'upload_media' ,'scope' => 'post_meta' ,'label' => __('Add Image','piklist') ,'description' => __('Add an icon image to this category.','piklist') ,'options' => array( 'modal_title' => __('Add Image','piklist') ,'button' => __('Add Image','piklist') ) ));Would you mind posting a code snippet of exactly how to use
get_term_metato extract the attached image URL from the currently queried taxonomy term? I’ve tried figuring it out from the WP codex but the seemingly applicable “get_” functions all seem to require a known term ID in the arguments…and this is where my inexperience with WP functions is getting me stumped. Here is a URL showing what I’m trying to accomplish: http://sccnew.speedofc.com/tb-staging/This is a listing of top-level categories from a custom taxonomy that I have created and displayed using the Types and Views plugin. My goal is to display the image attached to each category (via Piklist) next to each description below the title. Seems like it should be very simple. I have spent many hours Googling and crawling through the WP codex and the answer still eludes me.
jsperlMemberOk great…that gives me a good direction to start…thanks!
jsperlMemberHi Steve, thanks for answering…I really phrased the question wrong…what I really meant was displaying the field data on the front end as you referenced in your 2nd sentence. I’m not very experienced with writing code to extract and display data using get_post_meta and was looking for a good tutorial about ways to do that (I figured it would be more a WordPress thing rather than Piklist-specific but I just thought you guys might know a good resource…but I can Google it)…although in my most immediate case, it’s taxonomy custom field values I’m looking to display.
jsperlMemberOk, I think I found what I was looking for:
http://piklist.com/user-guide/docs/piklist/file-structure/term/
jsperlMemberLooks like the image tag didn’t work. Here is the URL to the screen grab reference the search result I mentioned:
-
AuthorPosts