Tagged: x
-
AuthorPosts
-
June 10, 2016 at 3:32 am #1035520
lisacole1Participanthi
http://www.carolinecasswell.co.ukCan I get rid of the sort box (which no one notices) and have a row of categories instead?
June 10, 2016 at 6:24 am #1035698
LelyModeratorHi There,
Are you referring to the plus sign filter on the right of the header on this link:http://www.carolinecasswell.co.uk/gallery/? If yes, that would need some customization.
Please add the following code on your child theme’s functions.php file:
// Output Portfolio Filters // ============================================================================= function custom_x_portfolio_filters() { $stack = x_get_stack(); $filters = get_post_meta( get_the_ID(), '_x_portfolio_category_filters', true ); $disable_filters = get_post_meta( get_the_ID(), '_x_portfolio_disable_filtering', true ); $one_filter = count( $filters ) == 1; $all_categories = in_array( 'All Categories', $filters ); // // 1. If one filter is selected and that filter is "All Categories." // 2. If one filter is selected and that filter is a category. // 3. If more than one category filter is selected. // if ( $one_filter && $all_categories ) { // 1 $terms = get_terms( 'portfolio-category' ); } elseif ( $one_filter && ! $all_categories ) { // 2 $terms = array(); foreach ( $filters as $filter ) { $children = get_term_children( $filter, 'portfolio-category' ); $terms = array_merge( $children, $terms ); } $terms = get_terms( 'portfolio-category', array( 'include' => $terms ) ); } else { // 3 $terms = array(); foreach ( $filters as $filter ) { $parent = array( $filter ); $children = get_term_children( $filter, 'portfolio-category' ); $terms = array_merge( $parent, $terms ); $terms = array_merge( $children, $terms ); } $terms = get_terms( 'portfolio-category', array( 'include' => $terms ) ); } // // Main filter button content. // if ( $stack == 'integrity' ) { $button_content = '<i class="x-icon-sort" data-x-icon=""></i> <span>' . x_get_option( 'x_integrity_portfolio_archive_sort_button_text' ) . '</span>'; } elseif ( $stack == 'ethos' ) { $button_content = '<i class="x-icon-chevron-down" data-x-icon=""></i>'; } else { $button_content = '<i class="x-icon-plus" data-x-icon=""></i>'; } // // Filters. // if ( $disable_filters != 'on' ) { if ( $stack != 'ethos' ) { if ( $stack == 'renew' ) { ?> <ul class="x-portfolio-filters-menu unstyled"> <li><a href="#" data-option-value="*" class="x-portfolio-filter selected"><?php _e( 'All', '__x__' ); ?></a></li> <?php foreach ( $terms as $term ) { ?> <li><a href="#" data-option-value=".x-portfolio-<?php echo md5( $term->slug ); ?>" class="x-portfolio-filter"><?php echo $term->name; ?></a></li> <?php } ?> </ul> <?php } else {?> <ul class="option-set unstyled" data-option-key="filter"> <li> <a href="#" class="x-portfolio-filters"><?php echo $button_content; ?></a> <ul class="x-portfolio-filters-menu unstyled"> <li><a href="#" data-option-value="*" class="x-portfolio-filter selected"><?php _e( 'All', '__x__' ); ?></a></li> <?php foreach ( $terms as $term ) { ?> <li><a href="#" data-option-value=".x-portfolio-<?php echo md5( $term->slug ); ?>" class="x-portfolio-filter"><?php echo $term->name; ?></a></li> <?php } ?> </ul> </li> </ul> <?php } ?> <?php } elseif ( $stack == 'ethos' ) { ?> <ul class="option-set unstyled" data-option-key="filter"> <li> <a href="#" class="x-portfolio-filters cf"> <span class="x-portfolio-filter-label"><?php _e( 'Filter by Category', '__x__' ); ?></span> <?php echo $button_content; ?> </a> <ul class="x-portfolio-filters-menu unstyled"> <li><a href="#" data-option-value="*" class="x-portfolio-filter selected"><?php _e( 'All', '__x__' ); ?></a></li> <?php foreach ( $terms as $term ) { ?> <li><a href="#" data-option-value=".x-portfolio-<?php echo md5( $term->slug ); ?>" class="x-portfolio-filter"><?php echo $term->name; ?></a></li> <?php } ?> </ul> </li> </ul> <?php } } }Then copy template-layout-portfolio.php from this folder: wp-content/themes/x/framework/views/renew to this: : wp-content/themes/x-child/framework/views/renew
Open the copied file then replace the code with the following:<?php // ============================================================================= // VIEWS/RENEW/TEMPLATE-LAYOUT-PORTFOLIO.PHP // ----------------------------------------------------------------------------- // Portfolio page output for Renew. // ============================================================================= ?> <?php get_header(); ?> <div class="x-container max width offset"> <div class="<?php x_main_content_class(); ?>" role="main"> <?php custom_x_portfolio_filters(); ?> <?php x_get_view( 'global', '_portfolio' ); ?> </div> <?php get_sidebar(); ?> </div> <?php get_footer(); ?>As you can see from the updated code above, we have added this line:
<?php custom_x_portfolio_filters(); ?>
That will display the list of category filters on top of the portfolio list.Then add the following CSS on Appearance > Customize > Custom > Edit Global CSS:
.x-portfolio-filters-menu { position: relative; display: block !important; background: transparent !important; } .x-portfolio-filters-menu li { display: inline-block; background: hsl(341,74%,40%); float: left; } .x-breadcrumbs-wrap >ul { /* To hide the default filter on the right side of the header*/ display: none; }Further customizations from here would be getting into custom development, which is outside the scope of support we can offer. If you need more in depth changes, you may wish to consult with a developer. X is quite extensible with child themes, so there are plenty of possibilities. Thanks for understanding.
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1035520 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
