MonthJune 2021

Display different FacetWP sorting options per URL

add_filter( 'facetwp_sort_options', 'options_per_url', 10, 2 );

function options_per_url( $options, $params) {
   $uri = FWP()->helper->get_uri();
   if ( $uri == 'demo/product-tag/catalog') { 
      $options = [      
         'default' => [
            'label' => __( 'New arrivals', 'fwp' ),
            'query_args' => [
               'orderby' => 'date',
               'order' => 'DESC',
            ]
         ],
         'popularity_new' => [
            'label' => 'Popual',
            'query_args' => [
               'orderby' => 'post_views',
               'order' => 'DESC',
            ]
         ]
     ];

 }
   else {
      $options = [           
         'price_asc' => [
            'label' => 'Price ASC',
            'query_args' => [
            'orderby' => 'meta_value_num',
               'meta_key' => '_price',
               'order' => 'ASC',
            ]
        ],
        'price_desc' => [
           'label' => 'Price DESC',
           'query_args' => [
              'orderby' => 'meta_value_num',
              'meta_key' => '_price',
              'order' => 'DESC',
           ]


     ],
   }
   return $options;
}

WooCommerce brands page with logos

I used the Categories Images plugin to add images to my attribute terms (pa_brands) and a custom template to create the actual page and add it in my menu.

<div class="row-flex">
		
   <?php foreach (get_terms('pa_brands') as $cat) : ?>
      <div class="child">
		
         <a href="<?php echo get_term_link($cat->slug, 'pa_brands'); ?>"><img src="<?php echo z_taxonomy_image_url($cat->term_id); ?>" /></a>
      </div>
   <?php endforeach; ?>
		
</div>
		
.row-flex {

   display:flex; justify-content: center; align-items: center; flex-wrap: wrap; 

}
.child {
    width: 189px;
    height: 150px;
    margin: auto;
    align-self: flex-start;
    display: flex;
    align-items: center;
 }