Hi,
the mega menu currently sorts all posts from any category according to date, most recently published first.
However we are at the moment working on adding a huge amount of posts from the past, which have a custom field “datum” set to the date of the event that it happened. So it can happen that an event from let’s say april 20th 2018, will have the correct date set in the “datum” field, but will be published by the date of today.
We would like to make this change for just one category, called camera_eye, where the posts should be published according to event date, not published date.
How would we achieve this ?
I already figured out where I could be doing this, given this post on your site earlier: http://www.screencast.com/t/jgjknQvhwDwh
We think this is one of the bits of code, but obviously we’d need to define asc or desc, and the custom field “datum”, we’re fairly sure that like this it won’t work.
$att['sort'] = 'datum'
parent::render($atts);
-
This topic was modified 7 years by
NickDeBaerdemaeker.
Hi,
Please read this documentations
-> https://codex.wordpress.org/Alphabetizing_Posts
-> https://codex.wordpress.org/Class_Reference/WP_Query
Hope this will help you to achieve what you want.
Thank you for your understanding.
-
This reply was modified 7 years by
Calin.
Im unsure what you mean by these links.
Do I have to create a category.php file, specific camera eye php file or simply use the code shown on these pages and insert that into the td black mega menu file from the theme ?
So far I got this, but yet again it’s still not behaving like it should.
Code is correct though, when I alter else { $wp_query_args['order'] = 'DESC'; to ascending it works, however the category if is not picked up…
case 'snort':
if (is_category( 'camera-eye' )) {
$wp_query_args['meta_query'] = array(
'datum_clause' => array('key' => 'datum','compare' => 'EXISTS')
);
$wp_query_args['orderby'] = array('datum_clause' => 'DESC', 'post_date' => 'DESC');
} else { $wp_query_args['order'] = 'DESC';
}
break;