Random WP_Query Tip

Home Forums Calendar Products Events Calendar PRO Random WP_Query Tip

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #30553
    Trevor
    Participant

    I was following this gist from this post: https://theeventscalendar.com/support/forums/topic/random-featured-event-custom-widget/#post-15378.

    I created the same type of custom WP_Query.
    However, orderby = ‘rand’ would not work. My event posts were never randomized. I had to change:

    ‘post_type’ = ‘tribe_events’
    to
    ‘post_type’ = array(TribeEvents::POSTTYPE)

    Hopefully this note saves someone the pain I went through. Not sure why it fixes it, was a total fluke I found this fix.

    Cheers,
    Trevor

    PS…sorry had to edit the code examples above so they didn’t get stripped. Not sure what the shortcodes are for inserting code snippets.

    #30563
    Barry
    Member

    Thanks for the tip Trevor.

    Unfortunately this forum doesn’t handle code very well – there are no bbcode style codes for instance – so the best idea is to use a service like Pastebin or Gist and link back from here.

    #30926
    Kyle
    Participant

    Thanks for this! Helped me out

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Random WP_Query Tip’ is closed to new replies.