Digital experiences for all disciplines
New Landing › How can we help? › Cardinal › Filter Portfolio using PARENT Categories Only
New Landing › How can we help? › Cardinal › Filter Portfolio using PARENT Categories Only
- This topic has 13 replies, 2 voices, and was last updated 9 years by Mohammad – SUPPORT.
-
Posted in: Cardinal
-
February 10, 2015 at 7:02 pm #148866
Hi There – We have a bunch of child categories under our Parent Categories for our portfolio. We’d like to keep the sort/filter area above the portfolio, but WE ONLY WANT TO SHOW PARENT CATEGORIES. The child categories are helpful for listing and for viewing on detail pages, but we’d only like to see the PARENT categories in the sorting area.
Any way to achieve this? Many thanks!February 11, 2015 at 1:27 pm #149068Hi,
Please provide me specific page url with issue so i can find a way to resolve the issue.
Thanks
MohammadFebruary 11, 2015 at 5:04 pm #149135This reply has been marked as private.February 12, 2015 at 4:31 am #149264HI Mohammad – Just making sure you saw the login info above? Thanks!!!
February 12, 2015 at 7:32 am #149279Hi,
Please try to paste given below code at functions.php of child.function sf_portfolio_filter($style = "basic", $parent_category = "") { $filter_output = $tax_terms = ""; if ($parent_category == "" || $parent_category == "All") { $tax_terms = sf_get_category_list('portfolio-category', 1); } else { $tax_terms = sf_get_category_list('portfolio-category', 1); } $filter_output .= '<div class="filter-wrap clearfix">'. "\n"; $filter_output .= '<ul class="post-filter-tabs filtering clearfix">'. "\n"; $filter_output .= '<li class="all selected"><a data-filter="*" href="#"><span class="item-name">'. __("Show all", "swiftframework").'</span></a></li>'. "\n"; foreach ($tax_terms as $tax_term) { $term = get_term_by('slug', $tax_term, 'portfolio-category'); if ($term) { $filter_output .= '<li><a href="#" title="' . $term->name . '" class="' . $term->slug . '" data-filter=".' . $term->slug . '"><span class="item-name">' . $term->name . '</span></a></li>'. "\n"; } else { $filter_output .= '<li><a href="#" title="' . $tax_term . '" class="' . $tax_term . '" data-filter=".' . $tax_term . '"><span class="item-name">' . $tax_term . '</span></a></li>'. "\n"; } } $filter_output .= '</ul></div>'. "\n"; return $filter_output; }
Thanks
MohammadFebruary 12, 2015 at 5:16 pm #149585Hi Mohammad –
Thanks for the reply but we are not totally sure on how use the theme child. Do you have documentation or a link on how to do it properly? Once it is ready, I will simply add the above code to the functions.php of the child theme, correct?Thanks for your help-
gFebruary 12, 2015 at 5:32 pm #149589Hi,
Please use this plugin to create child theme https://wordpress.org/plugins/one-click-child-theme/.Thanks
MohammadFebruary 12, 2015 at 7:05 pm #149621Hi There Mohammad –
Got it setup – but the plugin automatically deactivates itself because of the following errow : https://www.dropbox.com/s/91hyra2cv673j63/Screenshot%202015-02-12%2012.05.02.png?dl=0Any thoughts?
February 13, 2015 at 12:38 pm #149846Hi,
Please find the attached child theme.
Thanks
MohammadAttachments:
You must be logged in to view attached files.February 13, 2015 at 5:23 pm #150011Hi Mohammad –
I’ve successfully installed the child theme AND added your custom code, but it is not working to ONLY show the parent categories on this page: http://awesomesauce.ecollectivedesign.com/what/Instead, it shows ALL of the categories: both parent and child.
Let me know if there is something else we can do you ONLY show PARENT categories at the top of this page. Thank you .
February 13, 2015 at 5:47 pm #150017Hi,
I have resolved the issue so please check it now.function sf_portfolio_filter($style = "basic", $parent_category = "") { $filter_output = $tax_terms = ""; if ($parent_category == "" || $parent_category == "All") { //$tax_terms = sf_get_category_list('portfolio-category', 0,0); $get_category = get_categories( array( 'taxonomy' => 'portfolio-category','parent' => 0) ); $category_list = array( '0' => 'All' ); foreach ( $get_category as $category ) { if ( isset( $category->slug ) ) { $category_list[] = $category->slug; } } } else { //$tax_terms = sf_get_category_list('portfolio-category', 0,0); $get_category = get_categories( array( 'taxonomy' => 'portfolio-category','parent' => 0) ); $category_list = array( '0' => 'All' ); foreach ( $get_category as $category ) { if ( isset( $category->slug ) ) { $category_list[] = $category->slug; } } } $tax_terms = $category_list; $filter_output .= '<div class="filter-wrap clearfix">'. "\n"; $filter_output .= '<ul class="post-filter-tabs filtering clearfix">'. "\n"; $filter_output .= '<li class="all selected"><a data-filter="*" href="#"><span class="item-name">'. __("Show all", "swiftframework").'</span></a></li>'. "\n"; foreach ($tax_terms as $tax_term) { $term = get_term_by('slug', $tax_term, 'portfolio-category'); if ($term) { $filter_output .= '<li><a href="#" title="' . $term->name . '" class="' . $term->slug . '" data-filter=".' . $term->slug . '"><span class="item-name">' . $term->name . '</span></a></li>'. "\n"; } else { $filter_output .= '<li><a href="#" title="' . $tax_term . '" class="' . $tax_term . '" data-filter=".' . $tax_term . '"><span class="item-name">' . $tax_term . '</span></a></li>'. "\n"; } } $filter_output .= '</ul></div>'. "\n"; return $filter_output; }
Thanks
MohammadFebruary 13, 2015 at 5:55 pm #150022Scratch that, it seems to be working great now!!!! Perhaps I needed to be patient 😉
Thanks!!!!February 13, 2015 at 6:07 pm #150028Thank you Mohammad! I really appreciate all your help!
February 14, 2015 at 1:35 am #150100Hi,
You most welcome.
Thanks
Mohammad -
Posted in: Cardinal
You must be logged in and have valid license to reply to this topic.