Post Filters showing Categories not included in Selection

Home Forums Technical Theme Support STAX Theme Post Filters showing Categories not included in Selection

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #465666
    Lewis Hackfath
    Participant

    I have used the posts block to display a selection of posts (Team Members) on a page.
    I have only selected a few categories which relate to the office in which the Team Member Works at.
    However the filter buttons are showing all categories that have posts.
    I have attached an image for reference.

    Attachments:
    You must be logged in to view attached files.
    #465711
    Lewis Hackfath
    Participant

    Additionally is it possible to change the colour of the active filter? so it is easy to identify which filter is currently in place.

    #465727
    David Morgan
    Keymaster

    Hi Lewis,

    In order for the filters to work properly, you’ll need to setup a parent category with child categories beneath it. The child categories will act as your filters, and then you can select the parent category in the block setup options.

    Changing the color of the active filter will likely need to be done using CSS. If you can provide a link to the page I’ll be happy to provide the CSS.

    Thanks!

    #465742
    Lewis Hackfath
    Participant
    This reply has been marked as private.
    #465755
    Lewis Hackfath
    Participant

    Additionally I have been asked if it is possible to sort in alphabetical order?

    #465994
    David Morgan
    Keymaster

    Hi Lewis,

    The link to your site currently isn’t working.

    For simplicity sake, you could update your workaround styles to this instead:

    .team [data-filter=”.team”], 
    .team [data-filter=”.news”],
    .team [data-filter=”.project”],
    .team [data-filter=”.director”] {
      display:none;
    }

    However, you shouldn’t need to use this workaround. If you provide your WP admin login info I can take a look at your setup to see if your categories are setup properly for filtering.

    Currently there is only the option to sort by Ascending or Descending (newest to oldest, or oldest to newest). We could update your plugin code with the option to sort alphabetically using our One Change service.

    Thanks!

    #466012
    Lewis Hackfath
    Participant
    This reply has been marked as private.
    #466015
    Lewis Hackfath
    Participant

    Hi David,

    I’ve edited the OBB Plugin to allow for a “Order By” Field to be added to the Portfolio Block.
    This is working and functional with the default setting being “date” but gives the options to order by date, title or type.

    I’ve attached the two files I’ve made the code changes in as I feel these would be awesome to add into production and wanted to pass them on.

    #466016
    Lewis Hackfath
    Participant

    I was also able to edit the Nav Filter to only bring in categories of the posts in the WP_Query Object by updating the following in organic-blocks-bundle/classes/class-obb-portfolio.php

    
    <div class="obb-filter-buttons wp-block-button">
    							<?php
    							$terms = get_terms(
    								array(
    									'taxonomy'   => $taxonomy,
    									'object_ids' => wp_list_pluck( $portfolio_query->posts, 'ID' ), //added to retrieve only terms of the posts in the query
    									'hide_empty' => true,
    								)
    							);
    							$count = count( $terms ); // This counts the number of categories.
    							echo '<button class="obb-button wp-block-button__link secondary" data-filter="*">Show All</button>';
    							if ( $count > 0 ) {
    								foreach ( $terms as $term ) {
    									$termname = strtolower( $term->name );
    									$termname = str_replace( ' ', '-', $termname );
    									echo '<button class="obb-button wp-block-button__link secondary" data-filter=".' . esc_attr( $termname ) . '">' . esc_html( $term->name ) . '</button>';
    								}
    							} // In the above foreach loop, the code will return all the values stored in $terms array.
    							?>
    							</div>
    #466065
    David Morgan
    Keymaster

    Hi Lewis,

    That’s great! Thanks for sharing your updates!

    However, the files didn’t attach because PHP files can be uploaded. However, you could zip the files and attach the zip file, then we can implement your updates to the plugin.

    Thanks!

    #466070
    Lewis Hackfath
    Participant

    Hi David,

    Zip File Attached.

    I’ve only added the code for the Portfolio Block however it could be used for other post display blocks.

    Changes Made:
    – Add “Order By” Field to Portfolio Block to allow ordering by Date, Type or Name
    – Update Masonry Filter to only show Terms used on the posts being displayed
    – Update Masonry Filter to not show the Term selected in the Block settings as there is already a “Show All” button

    Attachments:
    You must be logged in to view attached files.
    #466214
    David Morgan
    Keymaster

    Awesome, thanks Lewis!

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.