Support » Plugin: Custom Content Shortcode » Conditional Formatting Question

  • Resolved KellyBalthrop

    (@kellybalthrop)


    I love this plug in. I am trying to display the content of taxonomy fields as a list of items separated by commas. I have a [loop] to display each post of a custom type, then a [for each] to iterate through each taxonomy field like so:

    [loop type="art_submission"]
    Title: [field title]
    Description: [field description]
    Worktype:[for each="worktype"] [each name],[/for]
    Gallery: [content gallery="native"]
    [/loop]

    The problem with code is that I always get a trailing comma after the last item in the taxonomy list “worktype”:

    Title: New Submission #3
    Description: This is a description area
    Worktype: Photography,

    I tried some code for a conditional like this:
    Worktype:[for each="worktype"][if last] [each name][else] [each name],[/if][/for]

    However the [if last] only refers to the outer loop, not the each loop. Is there a way to accomplish what I want out of the box or am I going to have to dig into some PHP for the template?

    https://wordpress.org/plugins/custom-content-shortcode/

Viewing 1 replies (of 1 total)
  • Plugin Author Eliot Akira

    (@miyarakira)

    Hello,

    I’ve run into this issue before, when trying to create a comma-separated list. In the latest update, I added a new parameter to both [loop] and [for] shortcodes, so you can set trim=”true” to remove extra space or comma at the end.

    Then I realized, there’s already a command to display a list of taxonomy terms for the post: [taxonomy worktype]

Viewing 1 replies (of 1 total)
  • The topic ‘Conditional Formatting Question’ is closed to new replies.