WordPress.org

Ready to get started?Download WordPress

Forums

Events Manager
[resolved] Recurring events create too many post in homepage (15 posts)

  1. ikki83
    Member
    Posted 1 year ago #

    Hi folks,
    i use you events manager plugin and i fall in love with it. :)
    I've got a problem: when i create a recurring event, it creates a post for every single day and it publishes them in homepage.
    It's possible to show only one post for the recurring events in home?

    I use this code to display events in homepage, insterted in functions.php:

    <?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(); ?>

    My site is http://www.giuriservice.com

    Thanks in advance for your support.

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

  2. agelonwl
    Member
    Posted 1 year ago #

    you can add attributes like recurring=1

    e.g. em_get_events( array('post_id'=>$post->ID,'recurring'=>1) )

    http://wp-events-plugin.com/documentation/event-search-attributes/

  3. ikki83
    Member
    Posted 1 year ago #

    how can i modify my code with yours?

  4. ikki83
    Member
    Posted 1 year ago #

    solved, i'm very tired today!

  5. ikki83
    Member
    Posted 1 year ago #

    ok, i wake up this morning and the problem is repeated automatically: i've found again the duplicated post in home page.
    To resume i've used this code in index.php for the wordpress loop:

    <?php get_header(); ?>
    <div class="content-wrapper">
    	<div class='gdl-page-item'>
    		<div class='sixteen columns'>
    
    			<?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_events( array('post_id'=>$post->ID,'recurring'=>1) ); ?>
    
    				<h4><?php echo $EM_Event->output('#_EVENTLINK'); ?></h4>
    
    			<?php endwhile; /* End loop */ ?>
    			<?php wp_reset_query(); ?>
    
    		</div>
    	</div>
    	<div class="clear"></div>
    </div>
    <?php get_footer(); ?>

    and this in funciotns.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;
    }

    I hope you can help me.

    [No bumping, thank you.]

  6. Jack_Sparr0w
    Member
    Posted 1 year ago #

    Hi,
    i've got the same problem. I've searched around the web but i can't find a solution.
    Please help.

    Thank you.

  7. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    do these recurring events repeat in the admin area? If not then I'd check the code you're using as above, because it's probably in there somewhere where the problem lies.

    for showing events on a homepage - http://justintadlock.com/archives/2010/02/02/showing-custom-post-types-on-your-home-blog-page

    ourpost type is event or the EM_POST_TYPE_EVENT constant

  8. ikki83
    Member
    Posted 1 year ago #

    the events repeat in admin area in "Events" section.

  9. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    could it be you duplicated them somehow?

    try deleting one and see, as if one event gets trashed and disappears from the search, it must have been duplicated somehow (e.g. recurring events?).

  10. ikki83
    Member
    Posted 1 year ago #

    it repeats because i create recurring events, but i just want that n homepage it will be displayed only one post to promote the event.
    If i delete the single events that the recurring option creates, i get my target but they will disappear from the events calendar, too,
    Please help me...

  11. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    i see, so they're not duplicates but recurrences which you want to hide.

    unfortunately this isn't possible without you creating custom php code for it, you'd need to loop through events check if they're a repeated recurrence and then show only if not shown before in the list.

    here's something (untested, hand-written) to get you started-

    $shown_recurring_id = array()
    foreach ( EM_Events::get(array('recurrence'=>1) as $EM_Event ){
      if( !in_array($EM_Event->recurring_id, $shown_recurring_id) ){
        //show event
      }else{
        //already shown
        $shown_recurring_id[] = $EM_Event->recurring_id;
      }
    }
  12. ikki83
    Member
    Posted 1 year ago #

    i've tried a lot of different kind of solutions based on this code, but no one seems to work.
    Can you help me?

  13. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    you'd need to hire a developer to help you further, e.g. try - http://jobs.wordpress.net

  14. ikki83
    Member
    Posted 1 year ago #

    ok thanks...
    another question:can you help me if i want to group recurring events in the Events Widget?
    I'm planning to buy the pro version, i need paypal support :)

  15. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    if it's the same principle as above, then you'd still need to hire a dev for that as it's the same thing.

    if you mean something else, maybe. one way to go for starters for grouping events together is the use of categories.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic