Tagged: archive, portfolio categories, sorting
-
AuthorPosts
-
December 20, 2014 at 3:02 am #370871
Hi Kriei Support!
I’m trying to change the sorting order in the archive pages for portfolio categories. I’d like them to display according to date modified, in descending order, but I can’t seem to get it to work by adding ‘orderby’ -> ‘modified’ and ‘order’ => ‘DESC’ to the $atts = array in archive.php. I tried adding the same two bits to the array in taxonomy_portfolio-entries.php, but it’s also a no-go.
is there another or a different file that I need to edit? Any help is appreciated. Thank you! Happy Holidays, Kriesi Support!
December 21, 2014 at 3:57 am #371135Hi scotthhahn!
please refer to this post: https://kriesi.at/support/topic/how-to-sort-the-category-alphabetically-by-sort-the-portfolio-items-by-date/#post-208629
Cheers!
AndyDecember 22, 2014 at 7:48 pm #371711Hi Andy,
I just went into my theme folder, and the loop file that is referenced in the post your linked me to doesn’t exist. loop-portfolio-single.php is the closest thing I see, but the lines of code mentioned in the linked post aren’t there.
December 22, 2014 at 8:10 pm #371734It looks like the post that’s referenced is the for the Angular theme, and not Enfold.
December 22, 2014 at 10:21 pm #371850Hey!
Try this plugin out, https://wordpress.org/plugins/post-types-order/, and let us know if it works for you.
They also have a similar plugin for categories, https://wordpress.org/plugins/taxonomy-terms-order/.
Cheers!
Elliott- This reply was modified 10 years ago by Elliott.
December 23, 2014 at 2:35 am #371928Manual re-ordering works, but automatic order does not. I’m trying to have it re-order automatically. Is this just not possible to achieve through enfold’s theme files?
December 23, 2014 at 5:39 pm #372163Hey!
Try adding this to the bottom of your functions.php file.
add_filter( 'pre_get_posts', 'angular_customization_portfolio_order' ); function angular_customization_portfolio_order( $q ) { if ( $q->query_vars['post_type'] == 'portfolio' ) { $q->set('order', 'DESC'); $q->set('orderby', 'modified'); } }
Best regards,
ElliottDecember 23, 2014 at 8:13 pm #372230Hi Elliot,
I added your code to the bottom of the child theme’s functions.php file and it’s still a no go. I’d already changed those items in the $atts array and in archive.php and taxonomy-portfolio-categories to ‘DESC’ and ‘modified’, with no effect. I’ve been playing around with it a little more, and it seems like none of the orderby parameters are having any effect on the order in which the portfolio entries are being displayed. Is it possible that there’s a default setting being implemented somewhere else that’s preventing changes to the arrays in archive.php and taxonomy-portfolio-categories.php from taking effect?
Regards,
ScottDecember 23, 2014 at 8:46 pm #372246Hey!
Hmm, it seems to be working fine on my XAMPP setup. Try uploading a fresh copy of the theme and then add that code back into the functions.php file.
Also be sure to deactivate all plugins while testing.
Best regards,
Elliott- This reply was modified 10 years ago by Elliott.
December 23, 2014 at 9:42 pm #372278Elliot,
I’m testing on a local copy in MAMP. I loaded a fresh instance of Enfold, updated it to the most current version (3.04), and disabled all plugins. It still isn’t having any effect.
Should I be updated to WordPress 4.1 (I’m running 4.01)? I’ve been holding been holding off until the plugins I’m using are verified to work.
Does it present a problem if the portfolio categories that are being used for the archives have subcategories? In most instances, there are two layers of subcategories, as below:
Portfolio Category A
-> Subcategory A
-> Sub-subcategory A
-> Sub-subcategory B
-> Subcategory B
-> Sub-subcategory A
-> Sub-subcategory B
Portfolio Category B
-> Subcategory A
-> Sub-subcategory A
-> Sub-subcategory B
-> Subcategory B
-> Sub-subcategory A
-> Sub-subcategory BThanks for all the help!
Regards,
ScottDecember 23, 2014 at 11:02 pm #372301Hey!
No that should not matter. Yes, make sure everything is updated.
Best regards,
ElliottDecember 24, 2014 at 12:07 am #372335Elliot,
I’ve updated to 4.1 and still no change. I added a column in admin to display the date modified for portfolio items and on the “Portfolio Items” admin page, the items are displaying in the correct order, but the changes aren’t extending to the taxonomy/archive pages.
Is there any additional information I can supply you with that might help figure this out?
Regards,
ScottDecember 24, 2014 at 12:58 am #372344Elliot,
I think I’ve figured it out:
I changed to code you have me from:
add_filter( 'pre_get_posts', 'angular_customization_portfolio_order' ); function angular_customization_portfolio_order( $q ) { if ( $q->query_vars['post_type'] == 'portfolio' ) { $q->set('order', 'DESC'); $q->set('orderby', 'modified'); } }
to:
add_filter( 'pre_get_posts', 'angular_customization_portfolio_order' ); function angular_customization_portfolio_order( $q ) { if ( $q->is_archive ) { $q->set('order', 'DESC'); $q->set('orderby', 'modified'); } }
Thanks for all of you help, Elliot–I appreciate it! Happy Holidays!
Regards,
Scott -
AuthorPosts
- The topic ‘Portfolio Category Archive Sorting’ is closed to new replies.