0

I want to hide a gallery on a one-page website. I use Album Gallery Plugin which enables me to insert the gallery as a php shortcode into the sourcecode.

I would like to have the entire DIV to be removed/hidden when the gallery is empty/set as draft

Here's the SC

<div id="photos" class="block" style="margin-top: 50% !important;">
    <h3>photos ></h3>
        <h4>Official photos<br>
        <small>XYZ ////////////////////</small></h4>
        <p>The Band:<br>
        XYZ<br>
        Drums<br>
        XYZ</p>
        <?php echo do_shortcode('[aigpl-gallery-slider id="1077" dots="false" arrows="false"]' );?>
        <h4>Live photos<br>
        <small>XYZ ////////////////////</small></h4>
        <p>XYZ live pictures</p>
        <?php echo do_shortcode('[aigpl-gallery-slider id="1080" dots="false" arrows="false"]');?>
</div>

My website uses mostly Custom Posts and I can hide the custom post div with wp query when the content is empty. But how do I do this in combination with a plugin?

1 Answer 1

1

This is just a matter of reorganising your PHP:

$gallery = do_shortcode('[aigpl-gallery-slider id="1080" dots="false" arrows="false"]');

if ( ! empty( $gallery ) ) {
    echo '<div id="photos" class="block" style="margin-top: 50% !important;">'
    ...
    echo $gallery;
    echo '</div>';
}
2
  • ok sounds like a way forward. but I have 2x shortcodes within that div. or can I use $gallery1 and $gallery2 and wrap that code in there?
    – mad2kx
    Commented Jun 8, 2018 at 13:13
  • Of course. You can evaluate all shortcodes first and use logic to decide on what to show under which circumstances.
    – cjbj
    Commented Jun 8, 2018 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.