Thread Starter
ksaffy
(@ksaffy)
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!
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
Thread Starter
ksaffy
(@ksaffy)
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.
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?
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?
@mohamedhamad maybe you want to also lower the “match threshold” so it’s not as strict about “relatedness”.
I’ve pretty much tried everything including stripping it down to just the post type and template. Still get zero results.
Thread Starter
ksaffy
(@ksaffy)
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.
Would you mind sharing your a tubal related posts code? I’d like to try out something that works
Thread Starter
ksaffy
(@ksaffy)
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.
@ksaffy did you put any related_posts() function in your theme to display the related events?
Thread Starter
ksaffy
(@ksaffy)
My events are shown as posts, so in event-single.php I added
<?php related_posts(); ?>
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?
Thread Starter
ksaffy
(@ksaffy)
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.
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);
} ?>