Order CPT by custom field

Posted in: Newspaper
Post count: 4

After successfully creating and running the td_api_plugin to display a Block of Custom Post Type “event” I need to order it using custom field “event_date”.

I have tried adding:


'meta_key' => '',
'orderby' => '',
'order' => ''

to $atts and assigned values to it:


$this->atts['meta_key'] = event_date;
$this->atts['orderby'] = event_date;
$this->atts['order'] = DESC;

The params are reflected correctly when I print_r($this->atts); inside td_block.php:

Array ( [limit] => 5 [sort] => [post_ids] => [tag_slug] => [autors_id] => [installed_post_types] => event [category_id] => [category_ids] => [custom_title] => NEXT EVENTS [custom_url] => [show_child_cat] => [sub_cat_ajax] => [ajax_pagination] => [header_color] => #000000 [header_text_color] => [ajax_pagination_infinite_stop] => [td_column_number] => 2 [td_ajax_preloading] => preload [td_ajax_filter_type] => td_tag_slug_filter [td_ajax_filter_ids] => 78, 79, 80, 81, 82, 90 [td_filter_default_txt] => All [color_preset] => [border_top] => [class] => td_uid_14_5822ad4fd6f60_rand [offset] => [css] => [live_filter] => [live_filter_cur_post_id] => [live_filter_cur_post_author] => [meta_key] => event_date [orderby] => event_date [order] => DESC ) Array ( [limit] => 6 [sort] => [post_ids] => [tag_slug] => [autors_id] => [installed_post_types] => post [category_id] => [category_ids] => [custom_title] => CONTENIDO [custom_url] => [show_child_cat] => [sub_cat_ajax] => [ajax_pagination] => next_prev [header_color] => #1e73be [header_text_color] => [ajax_pagination_infinite_stop] => [td_column_number] => 2 [td_ajax_preloading] => [td_ajax_filter_type] => td_category_ids_filter [td_ajax_filter_ids] => 72, 71, 37, 25, 29 [td_filter_default_txt] => All [color_preset] => [border_top] => [class] => td_uid_20_5822ad5005c1c_rand [offset] => [css] => [live_filter] => [live_filter_cur_post_id] => [live_filter_cur_post_author] => [meta_key] => event_date [orderby] => event_date [order] => DESC )

But the order of the posts is never altered. Has anyone dealt with this issue before? Any help will be very appreciated!

Post count: 23312

Hello mcquaas,

As a hint, you should change and add the new attributes and the conditions which are converted in arguments for wp-query. Look at the following screenshots -> http://screencast.com/t/Wm45Bqdnyhttp://screencast.com/t/rkcRR7cLqKhttp://screencast.com/t/6d3e4Qvzlhttp://screencast.com/t/3TZIA0cyS
Please notice that is not a simple task and if you are not aware of the steps which are needed to take in this regard, please consider hiring a freelancer/developer to help you because we cannot provide custom work at the moment, sorry!

Thanks for the message!

Post count: 11

Did you ever get a solution to this? I’m trying to get any of the blocks to sort by date from the Events Calendar, and I’m running into the same issue.

Post count: 23312

Hello d20games,

Unfortunately, the Events Calendar plugin is not tested with the theme and we cannot provide support for untested plugins.

Thanks for your understanding!

Post count: 4

We haven’t got to any satisfactory solution yet. But we found an (ugly and cumbersome) workaround while we get to it: order your post by the regular publication date and give every event a publication date exactly one year earlier. This way your events will be ordered by date (earlier first) and you just have to either a) delete events with past event dates or b) avoid their display by modifying the block.

We are using the td-plugin method and fiddled with the display (option b) so this is working fine on web.asdeporte.com if you want to see it working.

Cheers!

Post count: 11

Ok…forget about The Event Calendar. Do you have any means of displaying the built in Events within wordpress by event date order? If I can see that, I’ll know how to go and fix this.

I went looking through the samples, and coudn’t find any examples of Events treated in this way.

I’m frankly utterly shocked. If the nature of the theme is newspapers, being able to promote/list events is one of the most basic functions. And doing so would always be by soonest to latest.

Ben

Post count: 23312

Hello,

Unfortunately, our theme does not have any available ways in this regard, because the theme has not been designed to be used some event calendars, sorry! If you want to have something like this available on your website, you should implement it. Notice that is not a simple task and if you are not aware of the steps which are needed to take in this regard and if you do not have a solid knowledge and coding skills in this regard, please consider hiring a freelancer/developer to help you because we cannot provide custom work at the moment, sorry!

Thanks for the message!

Viewing 7 posts - 1 through 7 (of 7 total)
The forum ‘Newspaper’ is closed to new topics and replies.