[venues] 'orderby' => 'rand'

This topic contains 18 replies, has 2 voices, and was last updated by  Stephen Harris 11 years, 3 months ago.

Viewing 4 posts - 16 through 19 (of 19 total)
  • Author
    Posts
  • #7993

    Sorry, thats my English 🙁

    Thanks alot! Will try it tomorrow.

    And what about default number?

    Iurii Smuglov
    #8083

    No worries 🙂 (And apologies for the delay in getting back to you on this…)

    You can set a default number using similar code to that shown here: http://wp-event-organiser.com/documentation/developers/venue-meta-data-and-metaboxes/

    (On the eventorganiser_save_venue, check if it has the _order meta key, and if not, add it with the appropriate default value).

    Stephen Harris
    #8480

    Hi again, Stephen.
    I have 9 pages, for example, but do not have enough posts to fill all the pages. How can I set the number of pages dynamically, depending on the number of posts?

    Iurii Smuglov
    #8490

    Hi,

    You can dynamically set the number argument to the desired amount. If it i’ll depend on the total number of venues available then the following should get you that:

    $all_venues = eo_get_venues();
    $total_num_venues = ( $all_venues ? count( $all_venues ) : 0 );

    But you are having to do two queries now (there’s no way around that) – so for performance reasons I’d probably recommend you just hardcode it unless the number of venues is likely to fluctuate. Of course, you can also cache the result and just clear the cache whenever a new venue is updated.

    Stephen Harris
Viewing 4 posts - 16 through 19 (of 19 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.