WordPress.org

Ready to get started?Download WordPress

Forums

Events Manager
using {has_image} in template (7 posts)

  1. danhodkinson
    Member
    Posted 8 months ago #

    I'm bringing the formatting to my single-event.php template and it's all going fine, but the one thing I can't figure out is how to bring the if/else codes through e.g. {has_image} {/has_image} etc.

    Any ideas?

    Thanks
    Dan

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

  2. Harrison O.
    Member
    Posted 8 months ago #

    Hey Dan,
    The conditional placeholder checks to see if there is content assigned or not. Use it like a shortcode with any placeholder in the center:
    {has_image}#_EVENTIMAGE{/has_image}
    Or
    {has_image}#_EVENTIMAGE{100,100}{/has_image} This will show a thumbnail sized 100x100

    Harrison

  3. danhodkinson
    Member
    Posted 8 months ago #

    in my template i am using:
    `<?php echo $EM_Event->output('#_EVENTIMAGE');?>'
    to show an image.
    Using echo do shortcode in the template doesn't seem to work.

    Dan

  4. Harrison O.
    Member
    Posted 8 months ago #

    Try any of these to see if any works:
    <?php echo $EM_Event->output('format'=>'<div>{has_image}#_EVENTIMAGE{/has_image}</div>');?>

    I usually use the below format in my templates but never tried the conditional placeholder in it.
    <?php if (class_exists('EM_Events')) {
    echo EM_Events::output('format'=>'<div>{has_image}#_EVENTIMAGE{/has_image}</div>');
    } ?>

  5. Harrison O.
    Member
    Posted 8 months ago #

    Tested both codes above and they don't work. However this worked:

    <?php if (class_exists('EM_Events')) {
    	echo EM_Events::output( array('limit'=>0,'orderby'=>'start_date', 'category' => 13, 'format'=>'{has_image}#_EVENTIMAGE{/has_image}
    ') );
    } ?>

    You have to change the category id to the one you have there.

  6. danhodkinson
    Member
    Posted 8 months ago #

    Thanks for that!

    i've found that
    <?php if ( $EM_Event->output('#_EVENTIMAGE') ) = ' '): ?>
    also works, so i'll play about with both and see which i get along with

  7. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 8 months ago #

    or

    $EM_Event->get_image_url() == ''

    might work better

Reply

You must log in to post.

About this Plugin

About this Topic