New Landing How can we help? Cardinal Filter Portfolio using PARENT Categories Only

Viewing 14 posts - 1 through 14 (of 14 total)
  • Posted in: Cardinal
  • #148866
    ecollective
    Member
    Post count: 18

    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!

    #149068
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    Please provide me specific page url with issue so i can find a way to resolve the issue.
    Thanks
    Mohammad

    #149135
    ecollective
    Member
    Post count: 18
    This reply has been marked as private.
    #149264
    ecollective
    Member
    Post count: 18

    HI Mohammad – Just making sure you saw the login info above? Thanks!!!

    #149279
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    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
    Mohammad

    #149585
    ecollective
    Member
    Post count: 18

    Hi 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-
    g

    #149589
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    Please use this plugin to create child theme https://wordpress.org/plugins/one-click-child-theme/.

    Thanks
    Mohammad

    #149621
    ecollective
    Member
    Post count: 18

    Hi 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=0

    Any thoughts?

    #149846
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    Please find the attached child theme.
    Thanks
    Mohammad

    Attachments:
    You must be logged in to view attached files.
    #150011
    ecollective
    Member
    Post count: 18

    Hi 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 .

    #150017
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    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
    Mohammad

    #150022
    ecollective
    Member
    Post count: 18

    Scratch that, it seems to be working great now!!!! Perhaps I needed to be patient 😉
    Thanks!!!!

    #150028
    ecollective
    Member
    Post count: 18

    Thank you Mohammad! I really appreciate all your help!

    #150100
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    You most welcome.
    Thanks
    Mohammad

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

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register