WordPress.org

Support

Support » Plugins and Hacks » WP Calendar » [Resolved] [Plugin: WP Calendar] php problems for alternate text if there are no events

[Resolved] [Plugin: WP Calendar] php problems for alternate text if there are no events

  • Hi there,

    On my static ‘Home’-page I’m showing a list of the next upcomimg 3 events in one category.

    <?php fse_print_events(
    	array( 'number'   => 3,
    	'categories' => '5'
    	)
    	);?>

    all fine so far.

    But now i want to have a alternative text when there are no events in the list.

    I tried this:

    <?php
    if( is_array(fse_get_events(array('categories' => '4'))));
    {
    fse_print_events( array( 'number' => 3,'categories' => '4'));
    }
    else {
    echo "sorry no events";
    }
    ?>

    It doesn’t work and I’m little stuck here.
    You got help for me?

    Thanks in advance.

    http://wordpress.org/extend/plugins/wp-calendar/

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

    @faebu

    fse_get_events allways returns an array! you have to check, if it’s empty:

    <?php
    if( count(fse_get_events(array('categories' => '4'))) > 0);
    {
    fse_print_events( array( 'number' => 3,'categories' => '4'));
    }
    else {
    echo "sorry no events";
    }
    ?>

    Thanks faebu.
    unfortunately I get an error on the ” else “

    Parse error: syntax error, unexpected T_ELSE

    Can’t see whats wrong here.

    your snippet is inside the:


    <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>

    <?php
    if( count(fse_get_events(array(‘categories’ => ‘4’))) > 0);
    {
    fse_print_events( array( ‘number’ => 3,’categories’ => ‘4’));
    }
    else {
    echo “sorry no events”;
    }
    ?>

    <?php endwhile; ?>

    Plugin Author faebu

    @faebu

    problem is the ; in the first row. try this code again

    <?php
    if(count(fse_get_events(array('categories' => '4'))) > 0)
    {
      fse_print_events( array( 'number' => 3,'categories' => '4'));
    } else {
      echo "sorry no events";
    }
    ?>

    Thanks a lot.
    It’s working perfectly

    Plugin Author faebu

    @faebu

    nice to hear!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Resolved] [Plugin: WP Calendar] php problems for alternate text if there are no events’ is closed to new replies.
Skip to toolbar