• Resolved claudiaiw

    (@claudiaiw)


    Hi,

    is there a way to hide the block if it’s empty, instead of only showing “none found”?

    Regards
    Claudia

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Brecht

    (@brechtvds)

    Hi Claudia,

    If you make the “None found” text empty, nothing should show up if nothing is found. You can change that text in the sidebar when editing the block.

    Thread Starter claudiaiw

    (@claudiaiw)

    Great that works.

    I implemented the shortcode by PHP (because the widgets were not working) and wrapped a div around it for styling reasons (as there is none from the plugin..)

    function iw_related_posts() {
        echo '<div class="related-posts">' . do_shortcode( '[custom-related-posts title="Beitr?ge aus dem Projekt" none_text=""]' ) . '</div>'; 
    }
    add_action('generate_before_right_sidebar_content','iw_related_posts', 10);

    It would be perfect to set this into an if query, so that the div-wrap also doesn’t show up.

    Any hint for that?

    Thread Starter claudiaiw

    (@claudiaiw)

    As a workaround, I remove the element by jquery if it’s empty.

    Plugin Author Brecht

    (@brechtvds)

    You could put the output of the do_shortcode function in a variable first and check if that’s empty before outputting the surrounding div.

    Thread Starter claudiaiw

    (@claudiaiw)

    Sure ??
    that’s the better solution, thanks for the tip

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Hide if empty’ is closed to new replies.