Forum Replies Created

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • in reply to: How to display fields on front end? #1568
    jsperl
    Member

    var_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!

    in reply to: How to display fields on front end? #1566
    jsperl
    Member

    Thanks 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.

    in reply to: How to display fields on front end? #1562
    jsperl
    Member

    I’ve also tried

    $term = get_term( get_queried_object(), 'item-category' );
    $term_id = $term->term_id;
    in reply to: How to display fields on front end? #1561
    jsperl
    Member

    Thanks 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!

    in reply to: How to display fields on front end? #1554
    jsperl
    Member

    Sorry 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_meta to 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.

    in reply to: How to display fields on front end? #1532
    jsperl
    Member

    Ok great…that gives me a good direction to start…thanks!

    in reply to: How to display fields on front end? #1527
    jsperl
    Member

    Hi 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.

    in reply to: Are taxonomy custom fields still supported? #1513
    jsperl
    Member

    Ok, I think I found what I was looking for:

    http://piklist.com/user-guide/docs/piklist/file-structure/term/

    in reply to: Are taxonomy custom fields still supported? #1512
    jsperl
    Member

    Looks like the image tag didn’t work. Here is the URL to the screen grab reference the search result I mentioned:

    http://jacobperl.com/egspro/h176de96c#h176de96c

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