• Resolved jaeger

    (@jaegerschnitzel)


    Is there a possibility to hide the whole sidebar widget if no active poll is there?

    I think it’s not possible with dynamic widgets so I switched to a static entry in my sidebar.php theme file:

    <?php if (function_exists('vote_poll') && !in_pollarchive()): ?>
    <div class="widget widget_polls-widget">
        <h3>Polls</h3>
        <ul>
          <li><?php get_poll();?></li>
        </ul>
        <?php display_polls_archive_link(); ?>
      </div>
    <?php endif; ?>

    How can I achieve my goal?

    https://www.ads-software.com/plugins/wp-polls/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Lester Chan

    (@gamerz)

    You can do something like this, if it is not what you want, than I am afraid it is not possible.

    <?php if( intval( get_option( 'poll_currentpoll' ) ) !== -1): ?>
    <?php if (function_exists('vote_poll') && !in_pollarchive()): ?>
    <div class="widget widget_polls-widget">
        <h3>Polls</h3>
        <ul>
          <li><?php get_poll();?></li>
        </ul>
        <?php display_polls_archive_link(); ?>
      </div>
    <?php endif; ?>
    <?php endif; ?>
    Thread Starter jaeger

    (@jaegerschnitzel)

    Got it with your help ??

    <?php if (polls_latest_id() != 0 && function_exists('vote_poll') && !in_pollarchive()): ?>
    	<div id="polls-widget-2" class="widget widget_polls-widget">
    		<h3>Umfrage</h3>
    		<ul>
    			<li><?php get_poll();?></li>
    		</ul>
    		<?php display_polls_archive_link(); ?>
    	</div>
    <?php endif; ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘don't show widget if no active polls’ is closed to new replies.