-
AuthorPosts
-
September 23, 2015 at 9:06 pm #400601
Hi,
I’m looking to set my archive pages to display posts alphabetically. I understand I will need to customize the WordPress Loop to achieve this.
In which template file do I need to add the following arguments to the loop?
'orderby' => 'title', 'order' => 'ASC',
Thanks in anticipation of your assistance.
September 23, 2015 at 11:05 pm #400704Hello There,
Thanks for posting in.
X uses index.php for all the archives and pages. The files responsible for the archive pages can be found under wp-content/themes/x/framework/views/[your_stack]/ directory (e.g., wp-index.php).
Hope this helps.
September 30, 2015 at 10:31 pm #605795Hi,
Not really unfortunately. Let me be a little more specific: I have a category on my site called Information. On the category page for Information, I want the posts to be displayed in alphabetical order.
On a standard WordPress theme I would simply create the file category-information.php in my child theme and insert my customised loop with those arguments included in the loop. Easy as.
The file you pointed me to references a template at /global/_index.php here:
<?php x_get_view( 'global', '_index' ); ?>
I’ve duplicated both of those files into my child theme and can tell that they are being used because I’m able to add comments and see them in the source of my site.
Now, how do I apply a customized version of _index.php to only the information category?
Do I need to rename _index.php to category-information.php? Please point me in the right direction, it will be much appreciated.
Cheers,
BradSeptember 30, 2015 at 10:47 pm #605826Hello Brad,
You may just add the following code in your child theme’s function.php file.
add_action( 'pre_get_posts', 'x_category_order' ); function x_category_order($query){ if(!$query->is_main_query()) return $query; if(is_category('9')) $query->set( 'orderby', 'title' );$query->set( 'order', 'ASC' ); return $query; }
Replace 9 in
is_category('9')
with the correct category ID. To see your category id, please go to Posts > Categories > Click Edit under category Information look for tag_ID in the URL.
This link might help:https://community.theme.co/kb/how-to-locate-post-ids/Further customizations from here would be getting into custom development, which is outside the scope of support we can offer. If you need more in depth changes, you may wish to consult with a developer. X is quite extensible with child themes, so there are plenty of possibilities. Thanks for understanding.
October 1, 2015 at 3:19 pm #607036Thanks, that’s all I was after. Much appreciated!
October 1, 2015 at 6:24 pm #607269You’re most welcome Brad.
October 26, 2015 at 8:51 pm #640781Sorry to re-open this, but my next question is relevant to this. Have just noticed that my previous/next article nav buttons are now backwards- if i’m on project three, the next button takes me to project two, and the previous button takes me to project four. Is there another function I can add to rectify this? If not, I’ll just disable the nav buttons completely.
Cheers
October 26, 2015 at 10:08 pm #640843Hi there,
Thanks for updating the thread! Would you mind providing us with login credentials so we can take a closer look? To do this, you can make a post with the following info:
– Link to your site
– WordPress Admin username / password
– FTP credentialsDon’t forget to select Set as private reply. This ensures your information is only visible to our staff.
Note: We’ll try our best to find a solution however since this a customization outside the standard X, it is already beyond our scope. If we can’t find a simple solution then it may be best to disable the nav or engage a developer for a custom solution.
You can check out our recommended partners: https://theme.co/x/member/custom-development/
Thanks for understanding, take care and have a great day! 🙂
-
AuthorPosts