Tagged: #portfoliogrid #sortorder #menu
-
AuthorPosts
-
October 22, 2023 at 7:23 pm #1423331
Hi Kriesi,
I’ve looked for topic that would do this, with no luckI 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?
October 23, 2023 at 4:27 am #1423365Hey 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,
IsmaelOctober 23, 2023 at 11:03 am #1423388Great 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,
FrederikOctober 24, 2023 at 4:23 am #1423505Hi,
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 -
AuthorPosts
- You must be logged in to reply to this topic.