Support » Plugin: WP Rotator » order by custom post meta?

  • Resolved David Radovanovic

    (@dpaule)


    I’m using http://wp-events-plugin.com for an events custom post type. The events posts are being displayed via WP Rotator on the front page of chefsconsortium.com. Currently its order is based on when the post/event was created, though I need them to display based on the event start date (which is a meta field). Any way to achieve more control over WP-Rotator display i.e. display order based on a custom post type’s custom meta field?

    Thanks!

    http://wordpress.org/extend/plugins/wp-rotator/

Viewing 4 replies - 1 through 4 (of 4 total)
  • In other words, if I could achieve the following via Post Query Vars: post_type=event&orderby=event_start_date&order=DESC

    reghyz

    (@reghyz)

    Hi,

    take a look at this page : http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters

    under ” ‘orderby’ with ‘meta_value’ and custom post type ” you’ve got an exemple of a meta query thar you could add to your query vars,

    in your case it should be a thing like this instead i think :

    $args = array(
    ‘post_type’ => ‘event’,
    ‘meta_key’ => ‘event_start_date’,
    ‘orderby’ => ‘meta_value’,
    ‘order’ => ‘DESC’,
    ‘meta_query’ => array(
    array(
    ‘key’ => ‘event_start_date’,
    ‘compare’ => ‘LIKE’,
    )
    )
    );
    $query = new WP_Query($args);

    reghyz, thanks for the reply. Will I have to unhook the rotator function via: `remove_filter(‘wp_rotator_featured_cell_markup’,’wp_rotator_featured_cell_m arkup’);
    add_filter(‘wp_rotator_featured_cell_markup’,’be_wp_rotator_featured_cell_m arkup’); `

    This seems to have worked:

    post_type=event&orderby=meta_value&meta_key=event_start_date

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘order by custom post meta?’ is closed to new replies.