Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1423331

    Hi Kriesi,
    I’ve looked for topic that would do this, with no luck

    I need to be able to setup specific/manual orders for my sort order menus for my portfolio item elements on various pages. Can I do that, and if so, how?

    Example:
    In one menu I need “Pots & Vases” to always be the second button after the “All” button – “Large Planters” to be the third and “Accessories” to be the fourth.

    Can I force the links/buttons in a specific order?

    #1423365

    Hey frb1,

    Thank you for the inquiry.

    You can add this script in the functions.php file to manually re-order the category sort items.

    function av_custom_inline_script()
    {
    
        wp_add_inline_script( 'jquery', 
        "
        (function($) {
                // reorder category sort
                $(document).ready(function() {
                    $('.accessories_sort_button').insertAfter('.pots-vases_sort_sep');
                    $('.pots-vases_sort_button').insertBefore('.large-planters_sort_sep');
                });
        })(jQuery);
        "
        );
    }
    add_action( 'wp_enqueue_scripts', 'av_custom_inline_script' );

    Best regards,
    Ismael

    #1423388

    Great thank you Ismael! That worked perfectly – I managed to add script for other occasions of the portfolio-gris as well :)

    If I, by any chance, only should rearrange the buttons for one specific occasion of the portfolio-grid, would I then be able to ID that particular portfolio-grid? And then how what would the script look like? (If its possible)

    BR,
    Frederik

    #1423505

    Hi,

    And then how what would the script look like? (If its possible)

    You can prepend the ID to the sort buttons class name or selector. If the custom ID of the Porfolio Grid element is “custom-portfolio for example, the selectors will look like the following:

    $('#custom-portfolio .accessories_sort_button').insertAfter('#custom-portfolio .pots-vases_sort_sep');
     $('#custom-portfolio .pots-vases_sort_button').insertBefore('#custom-portfolio .large-planters_sort_sep');
    

    Of course, this can be optimized further but it’s such a little script, so it should be enough.

    Best regards,
    Ismael

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.