Last active
February 21, 2024 20:51
-
-
Save crawford252/20b9235f5674ed3da9f2e4aaa7348315 to your computer and use it in GitHub Desktop.
Divi FilterGrid - Custom Sort Dropdown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'dpdfg_custom_sorting_html', 'dpdfg_custom_sorting_html', 10, 2 ); | |
function dpdfg_custom_sorting_html( $sorting_options_html, $props ) { | |
if ( $props['module_id'] === 'custom-sorting' ) { | |
$sorting_options_html = sprintf( ' | |
<div class="dp-dfg-sort-orderby"> | |
<div class="dp-dfg-filters-dropdown closed" data-parent="0"> | |
<p class="dp-dfg-dropdown-label"><span class="dp-dfg-dropdown-placeholder" data-text="%1$s ">%1$s</span></p> | |
<ul> | |
<li class="dp-dfg-sort-option" data-value="date" data-order-value="ASC">%2$s</li> | |
<li class="dp-dfg-sort-option" data-value="date" data-order-value="DESC">%3$s</li> | |
<li class="dp-dfg-sort-option" data-value="title" data-order-value="ASC">%4$s</li> | |
<li class="dp-dfg-sort-option" data-value="title" data-order-value="DESC">%5$s</li> | |
<li class="dp-dfg-sort-option" data-value="default" data-order-value="ASC">%6$s</li> | |
<li class="dp-dfg-sort-option" data-value="default" data-order-value="DESC">%7$s</li> | |
</div> | |
</div> | |
', | |
$props['orderby_text'], | |
__( 'Oldest', 'dpdfg-dp-divi-filtergrid' ), | |
__( 'Newest', 'dpdfg-dp-divi-filtergrid' ), | |
__( 'Title (A to Z)', 'dpdfg-dp-divi-filtergrid' ), | |
__( 'Title (Z to A)', 'dpdfg-dp-divi-filtergrid' ), | |
__( 'Default (ascending)', 'td' ), | |
__( 'Default (descending)', 'td' ), | |
); | |
} | |
return $sorting_options_html; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment