Home Forums WoodMart support forum categories in the search bar

categories in the search bar

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #63932

    [email protected]
    Participant

    hey
    i would like to know how to get the categories in the search bar to be alphabetical
    thanks
    http://prntscr.com/jx99k7

    #63934

    Artem Temos
    Keymaster

    Hi,

    You can sort your categories manually with drag & drop function in Dashboard -> Products -> Categories.

    Regards

    #64328

    [email protected]
    Participant

    you can see here http://prntscr.com/jy2fz2 that I did do exactly that. it is all sort out, however, the search bar categories didn’t change. I need them to be in a alphabetical order, please.
    thanks.

    #64338

    Artem Temos
    Keymaster

    Try to add the following PHP code snippet to the child theme functions.php file to do this

    function woodmart_show_categories_dropdown() {
    		$args = array( 
    			'hide_empty' => 1,
    			'parent' => 0
    		);
    		$terms = get_terms('product_cat', $args);
    		if( ! empty( $terms ) && ! is_wp_error( $terms ) ) {
    			?>
    			<div class="search-by-category input-dropdown">
    				<div class="input-dropdown-inner woodmart-scroll-content">
    					<input type="hidden" name="product_cat" value="0">
    					<a href="#" data-val="0"><?php esc_html_e('Select category', 'woodmart'); ?></a>
    					<div class="list-wrapper woodmart-scroll">
    						<ul class="woodmart-scroll-content">
    							<li style="display:none;"><a href="#" data-val="0"><?php esc_html_e('Select category', 'woodmart'); ?></a></li>
    							<?php
    								if( ! apply_filters( 'woodmart_show_only_parent_categories_dropdown', false ) ) {
    							        $args = array(
    							            'orderby' => 'name',
    							            'title_li' => false,
    							            'taxonomy' => 'product_cat',
    							            'walker' => new WOODMART_Custom_Walker_Category(),
    							        );
    							        wp_list_categories($args);
    								} else {
    								    foreach ( $terms as $term ) {
    								    	?>
    											<li><a href="#" data-val="<?php echo esc_attr( $term->slug ); ?>"><?php echo esc_attr( $term->name ); ?></a></li>
    								    	<?php
    								    }
    								}
    							?>
    						</ul>
    					</div>
    				</div>
    			</div>
    			<?php
    		}
    	}
    #64342

    [email protected]
    Participant

    i got back this messeage
    Don’t Panic
    The code snippet you are trying to save produced a fatal error on line 39:

    Cannot redeclare woodmart_show_categories_dropdown() (previously declared in /home/myshopsu/domains/shopping.duvys.media/public_html/wp-content/themes/woodmart/inc/template-tags.php:1490)
    The previous version of the snippet is unchanged, and the rest of this site should be functioning normally as before.

    Please use the back button in your browser to return to the previous page and try to fix the code error. If you prefer, you can close this page and discard the changes you just made. No changes will be made to this site.

    #64380

    Artem Temos
    Keymaster

    Did you try to add it to the child theme functions.php file? You don’t need to use our theme’s file. If it will not help, please, provide us your FTP access so we can check it.

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