WordPress.org

Ready to get started?Download WordPress

Forums

Events Manager
[resolved] Don't show query if there are no results (5 posts)

  1. Chantal Coolsma
    Member
    Posted 1 year ago #

    I have a sidebar where I show some events with a specific tag:

    <?php if (class_exists('EM_Events')) {
    	echo EM_Events::output( array('scope'=>'future', 'tag'=>'win', 'limit'=>3,'orderby'=>'date', 'format'=>'...long code...') );
    } ?>

    Now it shows "NO EVENTS" when there are none. Is it possible to hide it when there are no events? Like "have_posts" does...

    http://wordpress.org/extend/plugins/events-manager/

  2. agelonwl
    Member
    Posted 1 year ago #

  3. Chantal Coolsma
    Member
    Posted 1 year ago #

    Can you be more specific please? Where do I place this code?

    if ( ! EM_Events::count( $atts ) > 0  ) return false;
    else return EM_Events::output( $atts );
  4. agelonwl
    Member
    Posted 1 year ago #

    you can replaced your snippet above with that code
    e.g.
    instead of

    <?php if (class_exists('EM_Events')) {
    	echo EM_Events::output( array('scope'=>'future', 'tag'=>'win', 'limit'=>3,'orderby'=>'date', 'format'=>'...long code...') );
    } ?>

    used

    if ( EM_Events::count( array('scope'=>'future','limit'=>3) ) == 0  ) echo '---';
    else echo EM_Events::output( array('scope'=>'future','limit'=>3, 'tag' => 'test' ,'format'=>'#_EVENTNAME<br/>' ) );
  5. Chantal Coolsma
    Member
    Posted 1 year ago #

    Ah thanks... However it should be:

    if ( EM_Events::count( array('scope'=>'future','limit'=>3) ) == 0 )

    (without ! in front of EM_Events) otherwise it only shows when there are no events ;-)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.