WordPress.org

Ready to get started?Download WordPress

Forums

WP Rotator
[resolved] order by custom post meta? (5 posts)

  1. David Radovanovic
    Member
    Posted 1 year ago #

    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/

  2. David Radovanovic
    Member
    Posted 1 year ago #

    In other words, if I could achieve the following via Post Query Vars: post_type=event&orderby=event_start_date&order=DESC

  3. reghyz
    Member
    Posted 1 year ago #

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

  4. David Radovanovic
    Member
    Posted 1 year ago #

    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'); `

  5. David Radovanovic
    Member
    Posted 1 year ago #

    This seems to have worked:

    post_type=event&orderby=meta_value&meta_key=event_start_date

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic