Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #172176

    Hey,

    I do need some more sorting options for the portfolio type. So I’d like to ask if anyone already created different sorting functions (especially using a child theme)…

    The portfolio item should be sorted based on categories in alphabetical order (ASC or DESC doesn’t matter) within it’s category and/or (!) it’s subcategories.

    It’s quite easy to have a random ordering but it’s all based on date added.

    I use the portfolio type to display products from different manufacturers. Each product has it’s product category and additionally a manufacturer category. So the sorting within the grid view should be by manufacturer alphabetically and within the manufacturer category by product name alphabetically.

    I’m capable of doing this on my own – just like to know if anyone else did this already.

    In addition it would be helpful to have a manual ordering on portfolio entries (like on pages post type).

    Thanks and regards!

    #172246

    Hey formateins!

    1) You can use following filter code to sort all items alphabetically:

    
    function custom_post_grid_query( $query, $params ) {
    $query['orderby'] = 'title';
    $query['order'] = 'ASC';
    return $query;
    }
    add_filter( 'avia_post_grid_query', 'custom_post_grid_query', 10, 2);
    

    If you want to use additional query parameters you just need to store them in the $query array. You can also use this hook to query the entries in a certain order if the default order parameters do not fulfill your requirements.

    2) If you want to sort the items manually I’d recommend to use this plugin: http://wordpress.org/plugins/post-types-order/ – it adds a drag’n’drop sorting feature to the admin panel.

    Regards,
    Peter

    #172260

    Hey Peter,

    thanks for the quick response. Thought already this way and I’ll try to add this as an option to the builder aswell.

    Don’t like to add _any_ additional plugins so I give the manual ordering a shot on my own. :)

    Regards,

    Joschi

    #172807

    Another question: while in single portfolio view there’s the prev/next navigation on left/right of the browser window. This func needs to be fixed too, as it still walks through the date created instead of alphabetical sorting.

    Screen: http://s7.directupload.net/file/d/3405/yyo8dgd6_jpg.htm

    Would be nice if you could point out the avia_hook so I can get this sorted aswell.

    Thanks!

    Edit:
    Having a few looks at the avia_post_nav in function-enfold and I’m sad to say I have to write my own function for this. :( Did have some reading on get_adjacent_post() and this function also hooks on static post_date in prepare call… Doh! This one will be tricky…

    • This reply was modified 1 year, 1 month ago by  formateins.
    #172891

    Hello!

    Yes, we use the standard get_adjacent_post() function which is quite limited at the moment. However they plan to improve it with wp3.8 ( http://core.trac.wordpress.org/ticket/17807 ).

    Cheers!
    Peter

    #172970

    I always love endless discussions over the years and nothing is happening… “future release” – so I won’t place a bet on 3.8 for that. :D

    Made a first step filling an array with all post id’s based on the sorting (bit tough with the post titles) and which are in the same category currently displayed, so I could walk one entry in each direction, grab post link and title and there we go. Bit messy for now, because it also affects the regular posts so I need to set the post type.

    Leave this post open for a few days – I’ll drop the code once it’s finished (and flexible enough). Have to buy another license of Enfold for a new customer… ;)

    Cheerio,

    Joschi

    #172973

    Hello!

    Btw – this thread: http://wordpress.stackexchange.com/questions/73190/can-the-next-prev-post-links-be-ordered-by-menu-order-or-by-a-meta-key may help you to hook into the get_adjacent_post function (sql query).

    If you want to use the “post types order plugin” see http://wordpress.org/support/topic/plugin-post-types-order-previous-next-navigation-wrong-order?replies=7

    Regards,
    Peter

    #172988

    Yeah, stumbled upon the topic on stack exchange (and some others), but they won’t work. Tried also to add the category, but it seems to run out of boundaries when getting into more nested levels.

    Otherwise I decide to simply disable the post nav for the portfolio type because it doesn’t make sense there. Won’t give up that fast… ;)

    Thanks again for the input! Appreciate that!

    #173126

    Hey!

    We’ll add an additional filter (“avia_post_nav_entries”) to the post_nav function (with the next update) which allows you to replace the content of the $entries array. You can then use the global $post variable and your custom function to replace the default get_previous_post/get_next_post urls with your urls if necessary.

    Regards,
    Peter

    #174662

    Ok,

    nice to hear that. I got that nav meanwhile close to a functional state (still bugs when on subcategory), but code is messy. So I won’t publish that here.

    Thanks for your help, guys!

Viewing 10 posts - 1 through 10 (of 10 total)

The topic ‘Portfolio – Sorting options’ is closed to new replies.