WordPress.org

Ready to get started?Download WordPress

Forums

Yet Another Related Posts Plugin (YARPP)
[resolved] Events Manager & YARPP (22 posts)

  1. ksaffy
    Member
    Posted 12 months ago #

    Hi,

    I'm using Events Manager with your plugin (great work btw) and I've got the related events pulling fine and the layout I want using a variation on your thumbnail template file. So far so good. The only issue I'm having is trying to work out how to exclude 'past' events from the results. If I set the 'Show only Clubs from the past' x d/w/m, it's not really helping with my issue as this uses the input or published date of the event rather than the event date. An event can be input months before the date of the event.

    Can you suggest some way for me to exclude all events when the event becomes a past event? Any help is very much appreciated.

    Thanks!

    http://wordpress.org/extend/plugins/yet-another-related-posts-plugin/

  2. ksaffy
    Member
    Posted 12 months ago #

    Having read through your other notes, I see that yarpp_map_post_types filter should be used. How would I use it? I'm semi-ok with php.

    Thanks!

  3. chadrew
    Member
    Posted 11 months ago #

    You could create a custom YARPP template file, and check the event date of every related post against today's date. In fact, I use something very similar, but I don't know how Events Manager stores the event date. In my case I store it in a custom field. If Events Manager does the same, then maybe this will help:

    http://pastebin.com/0J6ppaKg

  4. ksaffy
    Member
    Posted 11 months ago #

    Cheers for that! It's a little bit different as EM uses CPT, but using a variation of your code for the date option and it works like a wee charm - brilliant.

  5. mitcho (Michael Yoshitaka Erlewine)
    Member
    Plugin Author

    Posted 11 months ago #

    Glad you guys seem to have resolved this. @chadrew's tip is spot on.

    @ksaffy thanks for sharing the interesting use case! Can you share the site?

  6. mohamedhamad
    Member
    Posted 10 months ago #

    I've been having a hard time with this, and i dont seem to get any results from my related posts for an event.

    <?php if(function_exists('related_posts')): ?>
      <?php related_posts(array(
        'post_type' => array('event'),
        'show_pass_post' => false,
        'past_only' => false,
    
        'weight' => array(
          'body' => 1,
          'title' => 2,
          'tax' => array(
            'post_tag' => 1,
            'category' => 2,
          )
        ),
        'require_tax' => array(
            'post_tag' => 1
        ),
    
        'template' => 'yarpp-template-events.php',
        'limit' => 5,
        'order' => 'score DESC'
      ), $post->ID , true); ?>
    <?php endif; ?>

    I get no results. am i doing something wrong? can someone share their code please?

  7. mitcho (Michael Yoshitaka Erlewine)
    Member
    Plugin Author

    Posted 10 months ago #

    @mohamedhamad maybe you want to also lower the "match threshold" so it's not as strict about "relatedness".

  8. mohamedhamad
    Member
    Posted 10 months ago #

    I've pretty much tried everything including stripping it down to just the post type and template. Still get zero results.

  9. ksaffy
    Member
    Posted 10 months ago #

    Mitcho sure I can give you a link to the site. The site is for listing clubs and gigs:

    http://www.classicgrand.com/gigs

    Here's an example of a single event showing another shared event based on a shared custom taxonomy I created named 'Promoters'. I've also added in another custom taxonomy 'Genre', which is weighted less for related events.

    http://www.classicgrand.com/events/inside-the-ropes/

    @mohamedhamad, I'm using the built in yarpp-template-thumbnail.php, selected as a style in settings for the plugin. I've then just modified that .php file to suit what I want.

    http://pastebin.com/DSVqGxk0

    The only downside to the code is, if an event is past, the else message doesn't show. No time to work on resolving that but it's not a huge problem as we have so many events listed.

  10. mohamedhamad
    Member
    Posted 10 months ago #

    Would you mind sharing your a tubal related posts code? I'd like to try out something that works

  11. ksaffy
    Member
    Posted 10 months ago #

    I've not actually altered the code for the plugin at all. What have you got your plugin settings at? I have relatedness match threshold set to 1. In the display options, the php code is selected (not list, not thumbnail) and the template file 'Thumbnail' selected. The automatically display for posts, events, etc is unchecked for all post types.

  12. mohamedhamad
    Member
    Posted 10 months ago #

    @ksaffy did you put any related_posts() function in your theme to display the related events?

  13. ksaffy
    Member
    Posted 10 months ago #

    My events are shown as posts, so in event-single.php I added

    <?php related_posts(); ?>

  14. mohamedhamad
    Member
    Posted 10 months ago #

    ok, so your not specifying a custom post type of events to the related posts plugin.
    do you use related posts plugin for regular posts in your blog?

  15. ksaffy
    Member
    Posted 10 months ago #

    No I'm not, which is why I don't have anything checked for those options. I'm not showing it for any other posts / pages on my site, but if I want to all I would need to do is check them in the options. I only want to show related events and control how they're shown, so by using the php custom template and adding the related post function it works perfectly for me. My custom post type shows up in the options for YARPP, I just don't use it.

  16. mohamedhamad
    Member
    Posted 10 months ago #

    my custom post type shows up in yarp. i tried just using the regular related_posts(); function with no passed parameters, but it doesnt really work. only when i add parameters to it does it now show something.

    i've managed to get something showing by lowering the threshold to 3, the limit is working, the template is working, the order is working. but for some reason, i'm not able to set it to just work for events as a post type. it only shows blog posts. even if i remove the post type parameter, it shows blog posts and not event posts.

    <?php if(function_exists('related_posts')){
    		related_posts(array(
    	  'post_type' => 'event',
    	  'show_pass_post' => false,
    	  'past_only' => false,
    	  'threshold' => 3,
    	  'template' => 'yarpp-template-events.php',
    	  'limit' => 5,
    	  'order' => 'score DESC'
    	), $post->ID , true);
    } ?>
  17. ksaffy
    Member
    Posted 10 months ago #

    The file you've pasted the function in, is it for events only? Have you tried using the code above in your template but making sure NO Automatically display options for posts/pages/events are checked in the display option settings?

  18. mohamedhamad
    Member
    Posted 10 months ago #

    the code i just showed you is in the single-event.php
    There is no automatic output of related posts set at all, not even for blog posts.
    blog posts have a different template than the events.
    the events template is modelled on what is in this thread.

    you can check out what i mean here
    http://montreal.wherearetheshows.com/shows/horrible-things-3/

    it shows a blog post, and not any related event

  19. ksaffy
    Member
    Posted 10 months ago #

    OK, here's my full code for what I have in single-event.php (I've taken out the unnecessary code for other things I have). I'm using events manager, I'm assuming you're using the same.

    http://pastebin.com/JHR54Amb

    When <?php related_posts(); ?> is called, it should call the yarpp-template-thumbnail.php, if <?php custom and the Thumbnail template is selected in display options. So you shouldn't really need to define a related posts array in the function.

    Sorry but I can't think of anything else to help you to get it to work for your theme.

  20. mohamedhamad
    Member
    Posted 10 months ago #

    ok, seems like i managed to get somewhere, instead of related_posts(), i used related_entries() which seems to bring all post types with related info, e.g: shows posts, events and locations.

    now i'm filtering them out by finding if a result has an event id or not, and just display ones that do.

    not sure why i'm having different results and experience than you. i'm not doing anything to far off from what your doing.

  21. ksaffy
    Member
    Posted 10 months ago #

    Yeah! Well I'm glad you've got it sorted. I think the answer lies in the great mystery that is WordPress and themes.

  22. mohamedhamad
    Member
    Posted 10 months ago #

    fyi, this is what finally worked for me

    <?php if(function_exists('related_posts')){
    		related_entries(array(
    	  'post_type' => 'events',
    	  'show_pass_post' => false,
    	  'past_only' => false,
    		'weight' => array(
          'tax' => array(
            'event-tags' => 5,
    /* 					        'event-categories' => 5, */
        )),
        'require_tax' => array(
            'event-tags' => 2,
            'event-categories' => 1,
        ),
    	  'threshold' => 1,
    	  'template' => 'yarpp-template-events.php',
    	  'limit' => 5,
    	  'order' => 'date DESC'
    	), $post->ID , true);
    } ?>

Reply

You must log in to post.

About this Plugin

About this Topic