Random Events in Home Page

Home Forums Calendar Products Events Calendar PRO Random Events in Home Page

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #698536
    Giorgio De Novellis
    Participant

    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’ );
    }
    }

    #699287
    Brian
    Keymaster

    Sure we can help you out here.

    Try adding this:

    $query->set( 'eventDisplay', 'upcoming' );

    Let me know if that works.

    Thanks

    #700313
    Giorgio De Novellis
    Participant

    Hi Brian
    thanks for your help but the result is the same.
    Do you have any other suggestions?

    #701189
    Giorgio De Novellis
    Participant

    The URL of my web site:

    #701962
    Brian
    Keymaster

    Here 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.

    http://pastebin.com/jz8UaD3b

    I would try adding that coding’s meta_query to yours to get it to pull all future events from the current date.

    Thanks

    #703244
    Giorgio De Novellis
    Participant

    I 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.

    #704149
    Brian
    Keymaster

    Sorry 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

    #704299
    Giorgio De Novellis
    Participant

    Here you find our code “functions.php”
    http://pastebin.com/4ZNsfu2K

    We 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!

    #704559
    Brian
    Keymaster

    Ok 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.

    http://tribe.uservoice.com/

    Thanks

    #705675
    Giorgio De Novellis
    Participant

    This 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

    #706494
    Brian
    Keymaster

    Here is a link to the coding in Pastebin.

    http://pastebin.com/AhyMajCK

    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

     

    #706561
    Giorgio De Novellis
    Participant

    Brian, I do not know exactly what you did but now everything works:


    I do not really know how to thank you !!!

    #706585
    Brian
    Keymaster

    Your 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

    #706644
    Brian
    Keymaster

    By 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!

Viewing 14 posts - 1 through 14 (of 14 total)
  • The topic ‘Random Events in Home Page’ is closed to new replies.