• Resolved keubs

    (@keubs)


    I noticed you added it for version 1.5.24. This is perfect for what I’m trying to accomplish, but I can’t get it to work. Does the field need <?php ?> tags? Are arguments able to be passed in using tokens? Basically all I’m trying to do is print all of the tags associated with a post. Is this possible?

    Thanks

    https://www.ads-software.com/plugins/query-wrangler/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Jonathan Daggerhart

    (@daggerhart)

    Hi keubs,

    No, you don’t need to include any php in this field.

    There are a few ways to make this work using the_tags function (https://codex.www.ads-software.com/Function_Reference/the_tags)

    Easy way:

    1. Add a callback field to your query, and set the callback to ‘the_tags’, do not check ‘include additional information’.
    2. Save the field, and preview the query. You should see the tags for the posts listed.
    3. Save the query.

    If you want to customize the output a little more, here is a slightly harder way:

    1. Add a callback field to your query, and set the callback to ‘my_custom_the_tags’, check ‘include additional information.
    2. Save the field.
    3. Open your theme’s function.php file (or, somewhere else you’d like to store a custom function, could be a custom plugin) and add a new function that looks like this:
      function my_custom_the_tags($this_post, $field, $tokens){
        // now you can add custom arguments to the_tags function here
        the_tags("before tags", "between tags", "after tags");
      }
    4. Go back to the query and preview it. You should see your custom results.
    5. Save the query.

    This example field explains a little about the additional callback parameters that are included when you check the ‘Include Additional Information” setting for a callback field: https://gist.github.com/daggerhart/10417309

    Hope this helps. Let me know if it doesn’t make sense, or you run into other issues.

    Thanks,
    Jonathan

    Plugin Author Jonathan Daggerhart

    (@daggerhart)

    Just to clarify,

    In the second example, you don’t have to check “Include Additional Information” since the example custom function doesn’t make use of the $this_post, $field, or $tokens parameters.

    If you didn’t need those extra parameters, and didn’t “Include Additional Information”, then the callback function would look like this:

    function my_custom_the_tags(){
      the_tags("before tags", "between tags", "after tags");
    }

    Thread Starter keubs

    (@keubs)

    Hi Jonathan,
    So far I’ve tried adding the callback name “the_tags” to the field, to no avail. I’m pretty green on wordpress (originally a drupal dude) so I’m learning about “the loop”. Seems like the_tags isn’t being called within the context of this query, because when I debug that function, my breakpoint only hits once despite having 4 posts. I’ll keep researching, but I provided a screenshot to see if maybe I missed something small.

    Thanks

    ss:
    https://www.evernote.com/shard/s287/sh/b0cfd198-9bf1-475a-b65b-c4a6b28a3d95/ef56b95aad9194e9a0de208efd064214

    Plugin Author Jonathan Daggerhart

    (@daggerhart)

    I see your issue, you need to change the “Row Style” to “fields”. The “Post” row style is equivalent to Views “Node” row style. If the row style is “Posts”, then the fields aren’t ever rendered.

    Let me know how that works out for you.

    Thread Starter keubs

    (@keubs)

    Ha that worked! Of course it turns out to be some rookie mistake. Thanks a ton man. I wouldn’t have gotten that far if it weren’t for your first post, and I’ll be using the custom function stuff later on in the project, so your efforts to explain weren’t completely in vain.

    Plugin Author Jonathan Daggerhart

    (@daggerhart)

    No worries at all. Let me know if you run into other issues.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Callback Field (plugin version 1.5.24)’ is closed to new replies.