• Hi there,

    What I’d like to do is make it so that my accordions only display if there is content inside them, I can’t seem to figure out how to do it. At the moment, my accordions are displaying regardless, and that means that the user wastes time clicking through empty accordions, looking for content (not very user friendly).

    I’m using the accordions built into the Woo framework.

    Here is the code I’m using:

    </p>
    <p>[toggle title_open="Images" title_closed="Images" hide="yes" border="yes" style="default" excerpt_length="0" read_more_text="Read More" read_less_text="Read Less" include_excerpt_html="no"]
    [raw]<
    [block class="table-of-interactions"]
    [loop type="interaction" taxonomy="chapter" term="1" taxonomy_2="interaction-media-types" term_2="images" compare="and"]
    [fourcol_three]
    <h4 style="margin-bottom: 10px;">[field title]</h4>
    <p style="margin-bottom: 10px;">[field short_description format="true" length="365"]</p>
    <a href="[field url]">view</a>
    [/fourcol_three][fourcol_one_last]
    [field image="thumbnail" size="thumbnail"]</p>
    <p>[/fourcol_one_last]</p>
    <p><hr /></p>
    <p>[/loop]
    [/block]
    [/raw]
    [/toggle]

    Many thanks for any help

    https://www.ads-software.com/plugins/custom-content-shortcode/

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

    (@miyarakira)

    In the newest plugin update, I added a feature to check if a loop matches any posts before displaying content. It’s used like this:

    [loop exists type=interaction taxonomy=chapter term=1...]
    
      The content here will only be displayed if any posts match
    
      ..[block]..
    
      [the-loop]  <-- This will actually loop through the results
        ...[field url] etc..
      [/the-loop]
    
      ..[/block]..
    [/loop]
    Thread Starter mhairilongmuir

    (@mhairilongmuir)

    Hi there,

    In your plugin update, have you changed how we use the code to display posts? My posts are displaying differently than before (see screenshot), I have no idea why, I presume the way the code is being interpreted is different…

    Cheers,
    Mhairi

    Thread Starter mhairilongmuir

    (@mhairilongmuir)

    Oops, I can’t attached a screenshot!

    Thread Starter mhairilongmuir

    (@mhairilongmuir)

    I found out what it was…

    I hadn’t re-applied the settings that allowed me to use the html ‘block’ and ‘raw’ tags – switched back on and the block coding is gone.

    Cheers

    Thread Starter mhairilongmuir

    (@mhairilongmuir)

    so, back to the original request – making the accordions only display if there is content in the loop…

    The code you gave me (‘exists’) doesn’t work at the moment, when I add it to what I have there, because the accordion is outside the loop

    Do you know of any way that I can re-hash my code so that I can put the accordion inside the loop – I’ve had no success so far…

    [toggle title_open=”Video” title_closed=”Video” hide=”yes” border=”yes” style=”default” excerpt_length=”0″ read_more_text=”Read More” read_less_text=”Read Less” include_excerpt_html=”no”]
    [raw]
    [block class=”table-of-interactions”]
    [loop type=”interaction” taxonomy=”chapter” term=”1″ taxonomy_2=”interaction-media-types” term_2=”images” compare=”and”]
    [fourcol_three]
    <h4 style=”margin-bottom: 10px;”>[field title]</h4>
    <p style=”margin-bottom: 10px;”>[field short_description format=”true” length=”365″]</p>
    view
    [/fourcol_three][fourcol_one_last]
    [field image=”thumbnail” size=”thumbnail”]

    [/fourcol_one_last]

    <hr />

    [/loop]
    [/block]
    [/raw]
    [/toggle]

    Plugin Author Eliot Akira

    (@miyarakira)

    Did your settings get reset when you updated the plugin? It seems like that shouldn’t happen, that the settings should remain the same.

    If the new exists feature works correctly, you should be able to wrap the whole code block above in [loop exists] and use [the-loop] inside the accordion.

    [loop exists type=interaction taxonomy=chapter term=1...]
      [toggle][block]..
    
      [the-loop]  <-- This will actually loop through the results
        [fourcol_three]..
      [/the-loop]
    
      ..[/block][/toggle]
    [/loop]
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Dynamically display if there is content in the posts’ is closed to new replies.