Home › Forums › Calendar Products › Events Calendar PRO › Random Events in Home Page
- This topic has 13 replies, 2 voices, and was last updated 9 years, 8 months ago by Brian.
-
AuthorPosts
-
August 25, 2014 at 7:33 am #698536Giorgio De NovellisParticipant
Hi all
I’ve attached this to functions.php to view random events in Home Page, but I view also past events.
Can you help me?add_action( ‘pre_get_posts’, ‘random_posts’ );
function random_posts( $query ) {
if ( $query->is_home() && !$query->is_paged() && $query->is_main_query() ) {
$query->set( ‘orderby’, ‘rand’ );
}
}August 25, 2014 at 1:35 pm #699287BrianKeymasterSure we can help you out here.
Try adding this:
$query->set( 'eventDisplay', 'upcoming' );
Let me know if that works.
Thanks
August 25, 2014 at 11:27 pm #700313Giorgio De NovellisParticipantHi Brian
thanks for your help but the result is the same.
Do you have any other suggestions?August 26, 2014 at 6:35 am #701189Giorgio De NovellisParticipantAugust 26, 2014 at 11:57 am #701962BrianKeymasterHere is another suggestion for you.
This link shows more complex coding, but you maybe able to adapt the meta-query part into your coding to get it to work.
I would try adding that coding’s meta_query to yours to get it to pull all future events from the current date.
Thanks
August 27, 2014 at 1:30 am #703244Giorgio De NovellisParticipantI really appreciate your effort, but I’m not able to work on the code correctly.
I tried but I had to reinstall the code!
If I send you the code “functions.php”, can you help me?
I am of course willing to pay for your commitment.August 27, 2014 at 8:27 am #704149BrianKeymasterSorry it is not working, but…
Have you tried removing your coding and checking on this box in the Events Calendar General Settings Tab:
Include events in main blog loop
Does that work for you? Or were you adding the coding because it was not working?
Thank you for your offer to pay us to fix this, but I cannot accept that, however, we can referrer someone to you to do the work if you would like.
Thanks
August 27, 2014 at 9:28 am #704299Giorgio De NovellisParticipantHere you find our code “functions.php”
http://pastebin.com/4ZNsfu2KWe have inserted your code in place of “Add Random Events” line 222-232.
But we had a system crash.
As you can understand we are not programming experts.If you feel that we have no other alternative, I think it is appropriate to put us in touch with who can do the job.
Another thing, Brian.
Your plug-in seems very good indeed.
If there was the possibility of inserting a “Subtitle” and the possibility of a repetition of the events with different frequencies (think for example to the touring musical, …) would be great!August 27, 2014 at 12:09 pm #704559BrianKeymasterOk I was able to take a look and play around with it for a bit.
I got this coding to work for me:
Please see the pastebin link in the next reply.
I removed the ‘!$query->is_paged() &&’ from the coding as it was not working for me otherwise, but you may have to add it back.
As for a subtitle or different frequencies of recurring events we do not have those features, but please suggest them on our UserVoice page as that is where we get most of the ideas for new features.
Thanks
August 28, 2014 at 12:27 am #705675Giorgio De NovellisParticipantThis is the error:
Parse error: syntax error, unexpected ” => ” (T_CONSTANT_ENCAPSED_STRING), expecting ‘)’ in /web/htdocs/www.arte.go.it/home/wordpress/wp-content/themes/magazine-premium/functions.php on line 239
August 28, 2014 at 7:16 am #706494BrianKeymasterHere is a link to the coding in Pastebin.
Beyond that I cannot provide more support on this, the coding works for me on my development site.
So I am going to have to leave you to figure out the rest on this one to get it to work on your site. 🙂
Thanks
August 28, 2014 at 7:43 am #706561Giorgio De NovellisParticipantAugust 28, 2014 at 7:55 am #706585BrianKeymasterYour Welcome!
Glad it works, I think it was just copying and pasting from the forum caused an issue with the character types. So moving it to Pastebin fixed that.
And since this is resolved I am going to close this topic, but if you have any more issues or something new comes up please create a new ticket.
Thanks
August 28, 2014 at 8:31 am #706644BrianKeymasterBy the way, if you have a minute or two, we would love it if you’d write a few words for us here: http://wordpress.org/support/view/plugin-reviews/the-events-calendar?filter=5
Thanks!
-
AuthorPosts
- The topic ‘Random Events in Home Page’ is closed to new replies.