Filter Everything Shortcodes

Below, you’ll find a detailed guide on how to add the Filter Everything Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Filter Everything Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the Filter Everything Plugin and the shortcodes it provides:

Plugin Icon
Filter Everything — Product Filter & WordPress Filter

"Filter Everything – Product Filter & WordPress Filter is a top-tier plugin designed to enhance your site's search capabilities. It allows you to filter products and content, providing users a seamless browsing experience."

★★★★☆ (91) Active Installs: 20000+ Tested with: 6.3.2 PHP Version: 5.7
Included Shortcodes:
  • [fe_chips]
  • [fe_sort]
  • [fe_widget]
  • [fe_posts_found]

Filter Everything [fe_chips] Shortcode

The Filter Everything shortcode ‘fe_chips’ is designed to display selected terms with optional reset functionality. This shortcode allows customization with attributes such as ‘reset’, ‘mobile’, and ‘id’. If ‘reset’ is set to ‘no’, the reset function is disabled. The ‘mobile’ attribute enables visibility on mobile devices. The ‘id’ attribute accepts comma-separated term IDs for display. The shortcode returns HTML content, making it a useful tool for customizing term display on your website.

Shortcode: [fe_chips]

Parameters

Here is a list of all possible fe_chips shortcode parameters and attributes:

  • reset – Controls the visibility of the reset button
  • mobile – If set, the element is visible on mobile devices
  • id – A list of identifiers to specify the desired elements

Examples and Usage

Basic example – The shortcode is used to display the chips with default settings.

[fe_chips /]

Advanced examples

Displays the chips without the reset option. This is useful when you want to keep the selected filters active and not provide an option to reset them.

[fe_chips reset=no /]

Displays the chips only on mobile devices. This is useful when you want to show different content to users based on the device they are using.

[fe_chips mobile=yes /]

Displays the chips for specific sets. The id attribute can accept multiple comma-separated ids. This is useful when you want to show chips for specific sets only.

[fe_chips id=1,2,3 /]

Combines multiple attributes to customize the display of chips. In this example, the chips for sets 1 and 2 will be displayed without the reset option and only on mobile devices.

[fe_chips id=1,2 reset=no mobile=yes /]

PHP Function Code

In case you have difficulties debugging what causing issues with [fe_chips] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'fe_chips', [ $this, 'chipsShortcode' ] );

Shortcode PHP function:

function chipsShortcode( $atts )
    {
        ob_start();

        $showReset  = true;
        $setIds     = [];
        $classes    = [];

        if( isset( $atts['reset'] ) && $atts['reset'] === 'no' ){
            $showReset = false;
        }

        if( isset( $atts['mobile'] ) && $atts['mobile'] ){
            $classes[] = 'wpc-show-on-mobile';
        }

        if( isset( $atts['id'] ) ){
            $atts['id'] = preg_replace('/[^\d\,]?/', '', $atts['id']);
            $setIds = explode( ",", $atts['id'] );
        }

        flrt_show_selected_terms( $showReset, $setIds, $classes );

        $html = ob_get_clean();

        return $html;
    }

Code file location:

filter-everything/filter-everything/src/Admin/Shortcodes.php

Filter Everything [fe_sort] Shortcode

The Filter Everything shortcode ‘fe_sort’ enables sorting functionality on your WordPress site. It fetches the widget ID and displays the respective sorting widget. If no ID is provided, it prompts to specify one. If the ID is incorrect, it alerts the user.

Shortcode: [fe_sort]

Parameters

Here is a list of all possible fe_sort shortcode parameters and attributes:

  • id – It is the unique identifier of the Sorting widget.

Examples and Usage

Basic example – The basic usage of the ‘fe_sort’ shortcode allows you to display a specific sorting widget by referencing its ID.

[fe_sort id=1 /]

Advanced examples

If you want to display a sorting widget without specifying an ID, you can simply use the ‘fe_sort’ shortcode without any parameters. In this case, the function will try to find a sorting widget to display. If it finds more than one, it will display a debug message with the IDs and titles of all available sorting widgets. This feature is only available in debug mode.

[fe_sort /]

Another advanced usage of the ‘fe_sort’ shortcode is to specify an invalid ID. In this case, the function will display a message indicating that the ID is incorrect and that a valid ID should be specified. This feature is useful for troubleshooting and ensuring that the correct sorting widget is being displayed.

[fe_sort id=9999 /]

PHP Function Code

In case you have difficulties debugging what causing issues with [fe_sort] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'fe_sort', [ $this, 'sortingShortcode' ] );

Shortcode PHP function:

function sortingShortcode( $atts )
    {
        ob_start();
        $debug_mode   = flrt_is_debug_mode();
        $all_widgets  = get_option( 'widget_wpc_sorting_widget' );
        $possible_ids = [];
        $arguments    = [];
        $widget_id    = 0;

        if( isset( $atts['id'] ) ){
            $widget_id = preg_replace('/[^\d]?/', '', $atts['id'] );
        }else{

            if( is_array( $all_widgets ) && $debug_mode ){
                foreach ( $all_widgets as $id => $widget_args ){
                    if( ! isset( $widget_args['title'] ) ){
                        continue;
                    }

                    $possible_ids[ $id ] = $widget_args['title'] ? $widget_args['title'] : esc_html__( 'No title','filter-everything' );
                }

                if( ! empty( $possible_ids ) ){
                    $first_id = key( $possible_ids );
                    echo '<p class="wpc-debug-message">';
                    echo esc_html__('Please, specify desired Sorting widget by adding the id parameter to the shortcode.', 'filter-everything');
                    echo '<br />';

                    foreach ( $possible_ids as $id => $title ){
                        echo sprintf( esc_html__('Use «%d» as the id for the widget with the title «%s»','filter-everything' ), $id, $title );
                        echo '<br />';
                    }

                    echo '</p>';
                }else{
                    esc_html_e('There are no Sorting widgets on this site yet. Please, create it first.','filter-everything' );
                }

                flrt_debug_title();

            }
        }

        if( isset( $all_widgets[$widget_id] ) ){
            $arguments = $all_widgets[$widget_id];
            the_widget('\FilterEverything\Filter\SortingWidget', $arguments );
        }else{
            esc_html_e('Wrong Sorting widget id. Please, specify the correct.','filter-everything' );
        }

        $html = ob_get_clean();

        return $html;
    }

Code file location:

filter-everything/filter-everything/src/Admin/Shortcodes.php

Filter Everything [fe_widget] Shortcode

The ‘fe_widget’ shortcode of the Filter Everything plugin allows customization of the filter widget. It provides options to set the title, widget ID, chip display, count visibility, orientation, and column count.

Shortcode: [fe_widget]

Parameters

Here is a list of all possible fe_widget shortcode parameters and attributes:

  • title – sets the title of the widget
  • id – assigns a unique identifier to the widget
  • show_chips or show_selected – displays selected filter items
  • show_count – shows the number of items in each filter
  • horizontal – arranges filters in a horizontal layout
  • columns – defines the number of columns to display, between 2 and 5

Examples and Usage

Basic example – A simple usage of the ‘fe_widget’ shortcode to display a filter with a specified title.

[fe_widget title="My Filter" /]

Advanced examples

Utilizing the ‘fe_widget’ shortcode to display a filter widget with a specific ID, and enabling the display of chips and count.

[fe_widget id="123" show_chips="1" show_count="1" /]

Using the ‘fe_widget’ shortcode to create a horizontally oriented filter widget with a specific number of columns.

[fe_widget horizontal="1" columns="4" /]

Combining various parameters in the ‘fe_widget’ shortcode to display a filter widget with a specified title, ID, and additional settings such as chips, count, orientation, and columns.

[fe_widget title="My Filter" id="123" show_chips="1" show_count="1" horizontal="1" columns="4" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [fe_widget] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'fe_widget', [ $this, 'widgetFilterEverything' ] );

Shortcode PHP function:

function widgetFilterEverything( $atts )
    {   ob_start();

        $arguments = [];

        $arguments['title'] = isset( $atts['title'] ) ? $atts['title'] : '';

        if( isset( $atts['id'] ) ){
            $arguments['id'] = preg_replace('/[^\d]?/', '', $atts['id'] );
        }

        if ( isset( $atts['show_chips'] ) || isset( $atts['show_selected'] ) ) {
            $arguments['chips'] = 1;
        }

        if( isset( $atts['show_count'] ) ){
            $arguments['show_count'] = 1;
        }

        if( isset( $atts['horizontal'] ) ){
            $arguments['horizontal'] = 1;
        }

        if( isset( $atts['columns'] ) ){
            $count = intval( $atts['columns'] );

            if ( $count > 5 ) {
                $arguments['cols_count'] = 5;
            } elseif ( $count < 2 ) {
                $arguments['cols_count'] = 3;
            } else {
                $arguments['cols_count'] = $count;
            }
        }

        the_widget('\FilterEverything\Filter\FiltersWidget', $arguments );

        $html = ob_get_clean();
        return $html;
    }

Code file location:

filter-everything/filter-everything/src/Admin/Shortcodes.php

Filter Everything [fe_posts_found] Shortcode

The ‘fe_posts_found’ shortcode from the Filter Everything plugin allows you to display the number of posts found based on a specific set ID. It first checks if a set ID (‘sid’) is provided in the shortcode attributes. If not, it retrieves the first set ID from the related page sets. The function ‘flrt_posts_found’ is then called with the set ID as a parameter. The output is stored in a buffer and then returned as HTML. This means the posts found will be displayed where you place this shortcode in your content.

Shortcode: [fe_posts_found]

Parameters

Here is a list of all possible fe_posts_found shortcode parameters and attributes:

  • sid – Specifies the unique set identifier for the posts.

Examples and Usage

Basic example – A simple usage of the ‘fe_posts_found’ shortcode with a single parameter (sid).

[fe_posts_found sid=1 /]

Advanced examples

Utilizing the ‘fe_posts_found’ shortcode without any parameters. In this case, the shortcode will retrieve the first available ‘set_id’ from the ‘wpc_page_related_set_ids’ query variable.

[fe_posts_found /]

Using the ‘fe_posts_found’ shortcode with a sid parameter value that contains non-numeric characters. The shortcode will sanitize the sid value and only keep the numeric part.

[fe_posts_found sid="set1" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [fe_posts_found] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'fe_posts_found', [ $this, 'postsFound' ] );

Shortcode PHP function:

function postsFound( $atts )
    {
        $set_id = 0;

        if( isset( $atts['sid'] ) ){
            $set_id = preg_replace('/[^\d]?/', '', $atts['sid'] );
        }else{
            $wpManager = Container::instance()->getWpManager();
            $sets = $wpManager->getQueryVar( 'wpc_page_related_set_ids', [] );
            if ( isset( $sets[0]['ID'] ) && $sets[0]['ID'] ) {
                $set_id = $sets[0]['ID'];
            }
        }

        ob_start();

        flrt_posts_found( $set_id );

        $html = ob_get_clean();
        return $html;
    }

Code file location:

filter-everything/filter-everything/src/Admin/Shortcodes.php

Conclusion

Now that you’ve learned how to embed the Filter Everything Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *