Home › Forums › Calendar Products › Events Calendar PRO › Event guid wrong for recurring events
- This topic has 7 replies, 2 voices, and was last updated 10 years, 8 months ago by
Nico.
-
AuthorPosts
-
September 16, 2015 at 10:34 am #1005656
josephmak
ParticipantFor the events that are recurring, the guid (permalink) for the event is set to the website homepage instead of /all.
The error is occurring on both the home page and all individual event pages where the three random upcoming events are showing. I have used tribe_get_events() and randomized the results with shuffle() to get random events. The only arg I provided for the tribe_get_events query is start_date.
Can you please provide some insight as to how to correct this issue. If there were an easy way to tell that the event was recurring without checking the dates (this would break a multi day event), I could attempt to build the permalink.
I have dumped the event guid out above the event picture and provided a link to the staging site. Every refresh of the page should return a random set of events, and within those events, the recurring ones have an incorrect guid. “Central Alberta Beer Week Party” is one of the offending events.
September 16, 2015 at 11:12 am #1005676josephmak
ParticipantLooking further into the issue, I am unsure if it is just recurring events or if the problem is completely random. The “Central Alberta Beer Week Party” is not actually a recurring event, I just assumed it was because of the name. So I guess a more appropriate thread title would be “Random events guid wrong” ?
September 16, 2015 at 11:16 am #1005682josephmak
ParticipantThe live site might be a better place to test this as there are way more events on there. The url is albertabrewers.ca
September 17, 2015 at 8:18 am #1005978Nico
MemberHi there @josephmak,
Thanks for reaching out to us! Interesting issue here, I’ll help you out figuring what’s wrong with your script but for that I would need to have a copy of it.
Can you post the code for query and output of the events here?
Thanks,
NicoSeptember 18, 2015 at 8:22 am #1006458josephmak
ParticipantHi Nico,
I don’t believe I made a custom query for the listing page. I did a custom query for the home page where I am displaying the three random events. Both the event listing page and the individual featured events have incorrect urls and I can’t determine what is making some of them have correct urls and others just have the home url.
For the three random events that are displayed on the home page and on individual event pages, the code is as follows:
$args = array('start_date' => date('D, d M Y H:i:s')); $events = tribe_get_events($args); shuffle($events); //randomize the events so they show up differently each timeThen I created a function to display only the necessary information for the featured events:
/* custom event functions */ function output_asba_event($event){ $title = $event->post_title; //get the dates from start and end date preg_match_all("/([0-9]{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])/",$event->EventStartDate, $start_date); preg_match_all("/([0-9]{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])/",$event->EventEndDate, $end_date); $start_month = $start_date[2][0]; $start_day = ltrim($start_date[3][0], 0); $v = tribe_get_recurrence_start_dates($post_id); var_dump($event->guid); echo '<a href="'.$event->guid.'">' . tribe_event_featured_image($event->ID, 'thumbnail', false) . '</a>'; echo '<a href="'.$event->guid.'"><h4 class="asba-teal-title">' . $title . '</h4></a>'; switch ($start_month){ case '01': $start_month = 'January'; break; case '02': $start_month = 'February'; break; case '03': $start_month = 'March'; break; case '04': $start_month = 'April'; break; case '05': $start_month = 'May'; break; case '06': $start_month = 'June'; break; case '07': $start_month = 'July'; break; case '08': $start_month = 'August'; break; case '09': $start_month = 'September'; break; case '10': $start_month = 'October'; break; case '11': $start_month = 'November'; break; case '12': $start_month = 'December'; break; } echo '<h5 class="asba-home-event-date">'.$start_month.' '. $start_day . ' '; if(tribe_event_is_all_day($event->ID)){ echo "- All Day</h5>"; } else{ echo tribe_get_start_date($event, false, $format = 'g:i A') . '-' . tribe_get_end_date($event, false, $format = 'g:i A'); echo '</h5>'; } }I can’t seem to find the place where the default Events Calendar query is happening, I didn’t look all that hard 😛 I can send you a var_dump of the query from one of the templates if that would help?
September 18, 2015 at 2:53 pm #1006635Nico
MemberHey @josephmak,
Thanks for following up! I understood you where getting the ‘wrong URLs’ just in your ‘home page random events’, if this is happening all over the site then having your snippet doesn’t help much, sorry for my miss understanding 🙁
Taking a look into the site’s calendar -http://albertabrewers.ca/events/- I’m not able to find a broken link so not sure if I still don’t get the error you describe or if this was resolved at some point ?
I do see the event links on the homepage are still failing. Can you try to change this in your snippet:
https://gist.github.com/niconerd/97db257904d1312c2e3c
Please let me know if the change in the snippet makes it work,
Best,
NicoSeptember 18, 2015 at 3:32 pm #1006702josephmak
ParticipantNico, you are the man!
That worked perfectly. I guess I didn’t explore the API as well as I thought I had. Thanks so much for your solution 🙂
Amanda
September 21, 2015 at 7:56 am #1007029Nico
MemberHey Amanda,
You are welcome! Glad to hear it’s working now. There’s always something new to learn 😉
I’ll go ahead and close out this thread, but if you need help with anything else please don’t hesitate to create a new one and we will be happy to assist you.
Best,
Nico -
AuthorPosts
- The topic ‘Event guid wrong for recurring events’ is closed to new replies.
