0

I have an advanced custom field attached to every item in my portfolio (its another date) and I want to sort my portfolio by this field. Is this possible? I was hoping you could just swap the orderby for the custom name (which is date_sold) in:

[portfolio items="40" order="DESC" orderby="date_sold" columns="4" generate_thumbnail="true" show_title="true" show_excerpt="true" show_filters="true" filter_display="text" show_pagination="true" show_item_categories="false" link_behavior="detail_page" show_all_text="Show All" paginate="yes" categories="recent"]

Thanks for any help!

1
  • Please refer to the plugins documentation or support forum for help with plugin specific shortcodes.
    – kaiser
    Commented Feb 5, 2014 at 23:47

1 Answer 1

1

I just did someting like this with my portfolio. Here's what I used to get mine working:

$args = array(
    'post_type' => 'portfolio',
    'posts_per_page' => '-1',
    'meta_key' => 'date_received',
    'orderby' => 'meta_value_num',
    'order' => 'DESC'

);
remove_all_filters('posts_orderby');
$query = new WP_query($args);

I have a CPT and using ACF datepicker called "date_received". I had a lot of trouble getting the orderby to work, until I added remove_all_filters('posts_orderby');

1
  • Are you using Adaptive Shortcodes as well? I have tried changing this in plugins/adaptive-shortcodes/shortcodes/portfolio.php with no luck. I am worried because its set inline it is over-riding it? Is there a way to echo out what its sorting by when the page loads so I can just see what its set too? Commented Feb 5, 2014 at 22:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.