• Resolved RicardoRVM

    (@ricardorvm)


    I need make a conditional loop to show in the home of a web only the content I marked with a true/fase field.

    With tis code:

    <h5><span class="h-fina">EN</span> PORTADA</h5>
    [loop type=reportaje]
    [if field=sale_a_portada value=checked]
    <h1>[link][field titulo_de_portada][/link]</h1>
    [/loop][/if]

    it is oK, but the web shows the shortcode [/if], and if I delete the shortcode [/if], all is OK, woks fine,

    What am I doing bad?

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

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

    (@miyarakira)

    The shortcodes needs to end in the reverse order that they started:

    [loop]..[if]...[/if]..[/loop]

    This will check the [if] condition for each post in the loop. From your description, I think this is what you want.

    Just for example, another possibility is:

    [if]..[loop]...[/loop]..[/if]

    That will check the field for the current post, and display a loop if the condition is true.

    Thread Starter RicardoRVM

    (@ricardorvm)

    it doesn′y work.

    If I put the code:

    <h5><span class="h-fina">EN</span> PORTADA</h5>
    [loop type=reportaje]
    [if field=sale_a_portada value=checked]
    <h1>[link][field titulo_de_portada][/link]</h1>
    [/loop]

    it works, and the web is like I want, but f i put the code as you say, the wen doen′t show nothing.

    I use the DMS2 the pagelines, and the code is in a text-box. I probed with a widget, and doesn′t wor either.

    Sorry for my bad english…

    Plugin Author Eliot Akira

    (@miyarakira)

    I read your original message and found one more thing, that this is a true/false field. If you’re using Advanced Custom Fields, a true/false field has a value of 0 (false) or 1 (true).

    You can check if the field is true by comparing it to 1.

    [loop type=reportaje]
    [if field=sale_a_portada value=1]
      ...
    [/if]
    [/loop]

    The [if] shortcode needs a closing tag, same as the loop.

    The loop shortcode also can check for field value, so the above can be shorter:

    [loop type=reportaje field=sale_a_portada value=1]
    ...
    [/loop]
    Thread Starter RicardoRVM

    (@ricardorvm)

    Thanks! Now it works fine.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘I can′t close shortcode [if]’ is closed to new replies.