-
AuthorPosts
-
October 8, 2014 at 5:35 am #121215
Hi,
Is there a way to choose the order of how portfolio items are displayed on a portfolio archive page?
Many thanks for your help.
October 8, 2014 at 2:11 pm #121560Hi There,
Thanks for writing in,
Can you try adding this code below and see how it works
function cmk_custom_order( $wp_query ) { /* Get the post type from the query*/ $post_type = $wp_query->query['post_type']; /*If Post type is Portfolio*/ if ( $post_type == 'x-portfolio') { /* Set Order to Random*/ $wp_query->set('orderby', 'rand'); /* un-comment if not using random order */ //$wp_query->set('order', 'DESC'); } } /* Change Order settings before displaying the Postype*/ add_filter('pre_get_posts', 'cmk_custom_order');
I set the order to random so you’ll see right away if the code is working, just reload the page few times and if its working, the very first post should change every refresh
For the list of all order option please check WP Query order paramater http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters
October 10, 2014 at 5:23 am #122874That’s worked perfectly, thank you very much.
Hers is a link to the page in question:
http://rightanglecreative.co.uk/portfolio/I have looked at the link you provided regarding the various ways of ordering and the following two were of particular interest:
1 – ‘meta_value’ – Note that a ‘meta_key=keyname’ must also be present in the query. Note also that the sorting will be alphabetical which is fine for strings (i.e. words), but can be unexpected for numbers (e.g. 1, 3, 34, 4, 56, 6, etc, rather than 1, 3, 4, 6, 34, 56 as you might naturally expect). Use ‘meta_value_num’ instead for numeric values.
2 – ‘meta_value_num’ – Order by numeric meta value (available with Version 2.8). Also note that a ‘meta_key=keyname’ must also be present in the query. This value allows for numerical sorting as noted above in ‘meta_value’.If I wanted to order the portfolio items by a custom order to be visually best, would I assign one of the above to each post and then order as I wish? For example, 1 will be visual merchandising manual, 2 will be water bottles and so on…
If this is the case, how do I assign these orders to each post?
Thank you very much for your time and help.
October 10, 2014 at 11:54 am #123146There has to be a custom field that you are ordering by. You will have to add a custom post field to your portfolio items. You can do this by adding the information to the custom Fields box:
November 5, 2014 at 2:23 pm #139160Hi I read through this string, and am still unsure how I would re-order my portfolio index page. I would like to have control over which items go first, second, etc. (not random)
What are the steps to be able to do this without rebuilding all the portfolio pages from scratch?
November 5, 2014 at 8:31 pm #139330Hey there,
There’s no option for that currently so template modification is necessary. But, we have listed this in our feature request list and might include additional Portfolio sorting options in a future release.
Thanks.
November 6, 2014 at 10:35 am #139690That would be a super important option. Most use cases for ordering the display of thumbnails in portfolio index are not based on recency, but rather on how the thumbnails display in relation to one another. A lot of trial and error is necessary to come up with the final order. Thanks for considering this.
November 6, 2014 at 1:55 pm #139839No Problem,
Have a great day
November 15, 2015 at 5:24 pm #666209Useful (and somewhat obvious–for Portfolios) to have an order feature.
November 15, 2015 at 8:04 pm #666322Hello There,
Thanks for updating this thread!
We’re just glad that it has been useful to you.If you have any additional questions at this time we kindly ask that you open them up in a separate thread. The longer threads get in the forum, they become more difficult to support as they tend to drift off topic and they also make it troublesome for users trying to search for solutions. Keeping threads relevant to their original inquiry ensures that we can keep better track of what has been resolved and that users can more effectively find answers to similar issues they might be experiencing.
Thanks!
December 16, 2015 at 11:54 am #709458Hi there,
Here are two example pages that we are working on and have found to contain errors:
http://lathamshome.com/furniture/dining/dining-tables
http://lathamshome.com/furniture/dining/dining-chairsWe have used custom development within our Child Theme’s functions.php file (as advised above) to order the portfolio items alphabetically within these portfolio archive pages. BUT, even though most portfolio have successfully been ordered alphabetically, there are still a few that are not. For example, the “Hadstock Table” would appear before the “Harrogate Table – Extending”, “Harrogate Table – Large” and “Harrogate Table – Small” but it does not appear that way.
Could you please advise as to how we can fix this?
Here is the complete functions.php from our Child Theme:
<?php // ============================================================================= // FUNCTIONS.PHP // ----------------------------------------------------------------------------- // Overwrite or add your own custom functions to X in this file. // ============================================================================= add_filter( 'post_type_link', 'x_remap_portfolio_permalink_to_project_link', 10, 4); function x_remap_portfolio_permalink_to_project_link($post_link, $post, $leavename, $sample) { if ('x-portfolio' == $post->post_type) { $custom = get_post_custom($post->id); if (isset($custom['_x_portfolio_project_link']) && $custom['_x_portfolio_project_link'][0]!='') return $custom['_x_portfolio_project_link'][0]; } return $post_link; } function cmk_custom_order( $wp_query ) { /* Get the post type from the query*/ $post_type = $wp_query->query['post_type']; /*If Post type is Portfolio*/ if ( $post_type == 'x-portfolio') { /* Set Order to Random*/ $wp_query->set('orderby', 'name'); /* un-comment if not using random order */ //$wp_query->set('order', 'ASC'); $wp_query->set('order', 'ASC'); } } /* Change Order settings before displaying the Postype*/ add_filter('pre_get_posts', 'cmk_custom_order');
Thank you in advance for your help with this matter.
December 16, 2015 at 4:34 pm #709811Hello There,
Thanks for posting in. Upon checking your page, the ordering is correct.
Hadstock Table
Harrogate Table – Extending
Harrogate Table – Large
Harrogate Table – Small
Hastingwood Table
Havering TablePlease purge/delete cache if you have caching plugin or you may disable it first.
Always,
XMay 4, 2016 at 4:56 pm #913307Is there any new way of ordering portfolio items? I noticed the last time you wrote it would be added into themeco was quite some time ago… any updates since then?
May 4, 2016 at 10:45 pm #913708Hello There,
Regretfully there is no updates on this thread!
The above solution should work out for you. Please try it out. -
AuthorPosts