Viewing 10 replies - 31 through 40 (of 40 total)
  • Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    do you mwan WP_Query?

    If so, then yes, you just need to make sure post_type = event or the constant EM_POST_TYPE_EVENT

    This is the code i’m trying out, but it posts my events after published date, instead of start date.

    What is the EM_POST_TYPE_EVENT, and how do I use that? is there any documentation, examples?

    <?php
    	$loop = new WP_Query( array(
    	'post_type' => 'event',
            'posts_per_page' => 5,
    )); ?>
    
    <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
    
    <?php // added this to be able to use shortcodes and placeholders
    	$EM_Event = em_get_event($post->ID, 'post_id'); ?>
    
    	<h4><?php echo $EM_Event->output('#_EVENTLINK'); ?></h4>
    
    <?php endwhile; /* End loop */ ?>
    <?php wp_reset_query(); ?>
    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    not atm, working on it

    I mean like this:

    $loop = new WP_Query( array(
    	'post_type' => EM_POST_TYPE_EVENT,
            'posts_per_page' => 5,
    ));

    your way should work fine though, maybe you need to add this at the top

    global $post;

    Marcus: I was never able to use WP_Query like you described, but found another solution, and now it also sorts my events posts with start date instead of publish date.

    <?php
    	global $query_string;
    	query_posts( $query_string . '&post_type=event&posts_per_page=5' );
    ?>
    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    interesting, i wouldn’t think there’d be a difference there….

    Hi all, thanks for this snippet. I am trying to do the same but to only show events in the frontpage that are occuring TODAY’s date. How can I do that?

    thx

    I added aglonwl’s snipped into my functions.php

    add_filter( 'pre_get_posts', 'my_get_posts' );
    function my_get_posts( $query ) {
    	if ( is_home() && false == $query->query_vars['suppress_filters'] )
    		$query->set( 'post_type', array( 'post', 'event' ) );
    	return $query;
    }

    and the posts are now being displayed on the front page. However, the entire post is being displayed instead of a summary (as I’ve set in wp settings), and adding more tags does not help. How can I fix this?

    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    chances are you need to disable ‘override with formats’ in Events > Settings > Pages > Events List/Archives

    downside is this’d apply to the events page too, you could get round this by leaving that option on and adding this sort of thing:

    add_action('template_redirect','my_homepage_em_change');
    function my_homepage_em_change(){
    	if(is_home()){
    		add_filter('option_dbem_cp_events_formats',function(){return false;});
    	}
    }
    }

    disclaimer: not tested

    Hey Marcus, thanks for the quick response mate!

    I followed your advice, and disabled override with formats in Events List/Archives but that didn’t affect the front page.
    When I disabled formatting for Event Pages, this then caused the event posts on the front page to behave like regular ones (with the “more” tags working, which is all I really want), but of course without the map and other goodies from the formatting.

    Unfortunately, I couldn’t the code you gave code working, but from what I understand of it, it will disable formatting on posts only when they are on the home page, which will remove the maps and stuff once again, but I can live it that if it works.

    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    I think there’s an extra } in that code snippet. I played around with this and it worked for me:

    //prevents formatting on the homepage if the events in homepage mod is used
    function my_em_homepage_eventformats(){
    	if(is_home()){
    		add_filter('option_dbem_cp_events_formats',function(){return false;});
    	}
    }
    add_action('template_redirect','my_em_homepage_eventformats');

    problem now is that events with bookings still show the booking form, would require some more digging.

Viewing 10 replies - 31 through 40 (of 40 total)
  • The topic ‘[Plugin: Events Manager] Show events as regular posts (articles)’ is closed to new replies.