sort custom post type

Posted in: Newspaper
Post count: 39

I created a custom post types for events and i would like to sort them by their startdate.
I added the following code in an pre_get_posts action in td_wp_booster_functions.


if( isset($query->query_vars['post_type']) and $query->query_vars['post_type'] == 'event' ) {
$query->set('orderby', 'meta_value');
$query->set('meta_key', 'startdate');
$query->set('order', 'DESC');
}

Now my events are sorted the way I want them to in the backend, but in the frontend they still are sorted by their publish date. How can I change that?

Post count: 23312

Hello ananas,

Unfortunately, these customizations involve doing such a custom work and if you are not aware of it, please consider hiring a freelancer/developer to help you! All the information about our custom post type, please check here -> https://forum.tagdiv.com/custom-post-type-support/

Thanks for your understanding!

Post count: 39

I’ve got one more question about that topic.
All I need to know is how the filter-options in the tagdiv-composer (like post_type) are applied to the WP-Query. I really don’t understand, why
$query->query_vars['post_type'] == 'event'
code with this in an if-query is not executed in blocks of td composer, where I chose to display Posts of Post-Type events only.

Post count: 23312

Hello ananas,

Notice that you should check the td_composer core file if you want to edit something like this functionality, sorry! Also, you can check the td_config.php core file to check the array with this functionality of filter from TD Composer -> https://www.screencast.com/t/moPIqlQkVlB
Notice that we cannot provide additional customization and if you are not aware of the steps which are needed to take in this case, please consider hiring a freelancer/developer to help you! Basically, we recommend the developers from studio.envato.com.

Thanks for your understanding!

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