-
Author
-
January 29, 2016 at 16:12 #101156sharmstrModerator
See if this works…
Copy /kleo/page-parts/posts-related.php to your child theme (/kleo-child/page-parts/posts-related.php) and add the orderby date parameter to the argument list like…
replace
COPY CODE$args['tax_query'][] = array( 'taxonomy' => $tax, 'field' => 'id', 'terms' => $terms );
with this
COPY CODE$args['tax_query'][] = array( 'taxonomy' => $tax, 'field' => 'id', 'terms' => $terms, 'orderby' => 'date' );
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
January 29, 2016 at 16:13 #101159sharmstrModeratorMoving this because its not a bug.
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
January 29, 2016 at 17:14 #101182allspyParticipantHi,
This error is now visible where the related posts where present:
Parse error: syntax error, unexpected ”orderby” (T_CONSTANT_ENCAPSED_STRING), expecting ‘)’ in /home/sitedemo/public_html/wp-content/themes/kleo-child/page-parts/posts-related.php on line 44
Thanks
January 29, 2016 at 17:20 #101183sharmstrModeratorLooks like you either forgot the comma after $terms or when you copied the code, the quote marks got screwed up.
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
January 29, 2016 at 17:41 #101197allspyParticipantHi,
The code is exactly has you show.
The original on my file:
COPY CODEif (!empty($categories)) { foreach( $categories as $tax ) { $terms = wp_get_object_terms($post->ID, $tax, array('fields' => 'ids')); $args['tax_query'][] = array( 'taxonomy' => $tax, 'field' => 'id', 'terms' => $terms ); } } }
How it satys after the update:
COPY CODEif (!empty($categories)) { foreach( $categories as $tax ) { $terms = wp_get_object_terms($post->ID, $tax, array('fields' => 'ids')); $args['tax_query'][] = array( 'taxonomy' => $tax, 'field' => 'id', 'terms' => $terms, 'orderby' => 'date' ); } } }
Do you see anything wrong?
Thanks
January 29, 2016 at 18:15 #101209sharmstrModeratorNo I dont. I copied into my file and it works perfectly. No errors. If you want to give me access I’ll have a look.
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
February 5, 2016 at 14:41 #102290sharmstrModeratorNot sure why you were getting the error, I added the code and there were no errors.
In any case, I gave you the wrong code. Its fixed now and your related articles are in date order. You will lose that change during the next Kleo update since you’re not running the Kleo child theme. After you update, be sure to change ‘rand’ to ‘date’ at the top of the file.
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
February 5, 2016 at 15:03 #102298sharmstrModeratorThe code already limits to the same category. If the file is in your child theme, change ‘rand’ to ‘date’ at the top of the file as I’ve instructed.
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
-
AuthorPosts
The forum ‘General questions’ is closed to new topics and replies.
Related Articles that appear after a post are not presented by order date.
I really need to present related posts ordered by date. Any idea how to fix it?