-
Author
-
January 29, 2016 at 16:12 #101156
sharmstr
ModeratorSee 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 solutionJanuary 29, 2016 at 16:13 #101159sharmstr
ModeratorMoving 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 solutionJanuary 29, 2016 at 17:14 #101182allspy
ParticipantHi,
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 #101183sharmstr
ModeratorLooks 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 solutionJanuary 29, 2016 at 17:41 #101197allspy
ParticipantHi,
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 #101209sharmstr
ModeratorNo 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 solutionFebruary 5, 2016 at 13:24 #102273allspy
ParticipantHi,
Sorry for my late reply, I was with a severe flu and was in bed for the last days.
Here are the login details to the site and to cPanel.
Admin URL: http://www.realcorte.com/webdesignvip
User: webmaster
Pass: IPmaQdWGxNegMIjo(^A!eb8RcPanel details:
Access URL: https://server.wphost.ovh:2083/
User: realcorte
Pass: 902734014Please let me know if you need further details.
Thanks for your attention and help.
Regards
February 5, 2016 at 14:41 #102290sharmstr
ModeratorNot 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 solutionFebruary 5, 2016 at 15:01 #102296allspy
ParticipantHi,
I’m using child the, I’ve personalized the child theme name it’s “Web Design Vip”. It was here where I’ve copied the posts-related.php to, the child theme and pasted there the code you sent me.
Can you please confirm if I need to copied the file again as you added it in to the main theme.
However I just checked and the related posts aren’t ordered.
May the be by the fact that we have several posts categories on the site? Can we limited the related posts to the one’s in the same category?
Thanks
February 5, 2016 at 15:03 #102298sharmstr
ModeratorThe 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 solution -
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?