Tagged: x
-
AuthorPosts
-
February 3, 2017 at 5:08 am #1356590
Steve CParticipantI would like to be able to order posts on the site by their title. I saw an older post that provided some custom code to go into the functions.php but I think it is probably outdated now?
Each post entry’s title will have a number at the beginning of it, so I would like to be able to set the order to show the smallest number first in the list of blog posts. (descending?)
I have a child theme setup so would ideally like to set this so that it remains set after theme updates etc.
Thanks,
SteveFebruary 3, 2017 at 8:03 am #1356733
Paul RModeratorHi Steve,
You can add this in your child theme’s functions.php file.
function foo_modify_query_order( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( 'orderby', 'title' ); $query->set( 'order', 'ASC' ); } } add_action( 'pre_get_posts', 'foo_modify_query_order' );Hope that helps.
February 3, 2017 at 9:00 am #1356796
Steve CParticipantThanks that has made a difference to the post order, although it’s not working as I’d like it to.
As it’s being order by number and not alphabetically it seems to order the posts as 1, 10, 100 etc. rather than 1,2,3…8,9,10,11.
Do you know if it’s possible to organise the posts in numerical order instead?
February 3, 2017 at 11:30 am #1356962
RahulModeratorHey There,
Thanks for writing in!
To assist you with this issue, we’ll first need you to provide us with your URL. This is to ensure that we can provide you with a tailored answer to your situation. Once you have provided us with your URL, we will be happy to assist you with everything.
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1356590 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
