Display only certain categories by passing it in the shortcode
-
Hello,
I just hardcode your plugin on my side because I need to display only certain categories as tabs.
Then, I am currently able to use the shortcode like this :
[wtcpl-product-cat term_ids="107,104,137"]
Here, look at my code :
function wtcpl_load_products($atts) // see $atts { $atts = shortcode_atts( array( 'term_ids' => false ), $atts, 'woo-tabbed-category-product-listing' ); $term_ids = sanitize_text_field( $atts['term_ids'] ); // see $term_ids if (!is_admin()) { ob_start(); $product_number = get_option('product_number'); $column_number = get_option('column_number'); ?> <div class="wtcpl_container"> <div id="nav-holder"> <div class="wtcpl_category_nav" id="wtcpl_tabs"> <?php // If term_ids attribute if ( !empty( $term_ids ) ) { // Term string to array $include = $term_ids; } else { $include = ''; } // see $include $args = array( 'number' => '', 'hide_empty' => 1, 'include' => $include // here we you this var );
Good idea right ?
Many modules in themes or page builders allow people to filter only certain categories. What you think ?
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Display only certain categories by passing it in the shortcode’ is closed to new replies.