admin管理员组

文章数量:1123938

The site I am working on has a function in the theme (Botiga) that creates a wrapper row that displays a sorting dropdown for the items below. The default output is the dropdown displays in the right column of the row, the left column is empty. I want to add another dropdown to the page and I want to insert it into the left column.

Here is the original code in functions.php of the theme that displays the wrapper row with the sorting dropdown in the right column:

/**
 * Wrap items results and ordering before
 */
function botiga_wrap_items_results_ordering_before() {
    if( ! botiga_has_sorting_wrapper() ) {
        return;
    }

    echo '<div class="sorting-wrapper">';
    echo '<div class="row">';
    echo '<div class="col-md-6 col-6 botiga-sorting-left">';
    echo '<div class="botiga-sorting-left-inner">';
}
add_action( 'before_shop_loop', 'botiga_wrap_items_results_ordering_before', 19 );

/**
 * Add a button to toggle filters on shop archives
 */
function botiga_add_filters_button() {
    if( ! botiga_has_sorting_wrapper() ) {
        return;
    }

    echo '</div>';
    echo '</div>';
    echo '<div class="col-md-6 col-6 botiga-sorting-right">';
    echo '<div class="botiga-sorting-right-inner">';
}
add_action( 'before_shop_loop', 'botiga_add_filters_button', 22 );

/**
 * Wrap items results and ordering after
 */
function botiga_wrap_items_results_ordering_after() {
    if( ! botiga_has_sorting_wrapper() ) {
        return;
    }
    
    echo '</div>';
    echo '</div>';
    echo '</div>';
    echo '</div>';
}
add_action( 'before_shop_loop', 'botiga_wrap_items_results_ordering_after', 31 );

/**
 * Check if has "sorting-wrapper"
 */
function botiga_has_sorting_wrapper() {
    $shop_grid_list_view  = get_theme_mod( 'shop_grid_list_view', 0 );
    $shop_product_sorting = get_theme_mod( 'shop_product_sorting', 1 );
    $shop_results_count   = get_theme_mod( 'shop_results_count', 1 );
    $shop_archive_sidebar = get_theme_mod( 'shop_archive_sidebar', 'no-sidebar' );

    if( ! $shop_grid_list_view && ! $shop_product_sorting && ! $shop_results_count && $shop_archive_sidebar !== 'sidebar-slide' ) {
        return false;
    }

    return true;
}

This is the widget code that displays the category dropdown that I want to insert in the left column of the wrapper: the_widget( 'Widget_Product_Categories', 'dropdown=1' );

I've been playing around with recreating the functions in my child theme functions.php by removing the existing actions and creating my own, but all I got was two separate wrappers, one with the category dropdown in the left column and a separate one with the sorting dropdown in the right column. I am unsure how to proceed. Can anyone lead me in the right direction?

本文标签: phpTrying to insert widget code into theme function