Essential Content Types Shortcodes

Below, you’ll find a detailed guide on how to add the Essential Content Types 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 Essential Content Types Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the Essential Content Types Plugin and the shortcodes it provides:

Plugin Icon
Essential Content Types

"Essential Content Types is a versatile WordPress plugin that enables you to effortlessly manage and display different types of content like testimonials, services, and portfolio, improving your website's functionality."

★★★✩✩ (2) Active Installs: 40000+ Tested with: 6.2.3 PHP Version: false
Included Shortcodes:
  • [featured_content]
  • [food_menu]
  • [portfolio]
  • [services]
  • [jetpack_testimonials]

Essential Content Types [featured_content] Shortcode

The Essential Content Types plugin’s ‘featured_content’ shortcode is a powerful tool for displaying featured content on your WordPress site. This shortcode allows you to control various aspects of the featured content display, including whether to show images, content types, tags, authors, and more. It also provides options for filtering content by type or tag, determining the number of columns, and setting the order of posts. The shortcode ensures the validity of inputs and sanitizes them for secure usage. It enqueues the necessary styles when used, delivering a seamless viewing experience.

Shortcode: [featured_content]

Parameters

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

  • image – Determines if the image should be displayed or not
  • display_types – Decides if the content types should be shown
  • display_tags – Controls if the tags should be displayed
  • display_content – Decides if the content should be shown
  • display_author – Controls whether the author’s name is displayed
  • show_filter – Indicates if a filter should be shown
  • include_type – Specifies the types of content to include
  • include_tag – Specifies the tags to include
  • columns – Sets the number of columns for the content
  • showposts – Determines the number of posts to show
  • order – Sets the order of the content, either ascending or descending
  • orderby – Specifies how the content should be ordered

Examples and Usage

Basic example – Displaying featured content with default attributes

[featured_content /]

In this basic example, the shortcode [featured_content /] is used to display the featured content. Since no attributes are specified, the default attributes specified in the PHP function ‘featured_content_shortcode’ will be used. This includes displaying the image, types, tags, and content of the featured content, but not the author. The content will be displayed in 2 columns and the order of the content will be ascending by date.

Advanced example – Displaying featured content with custom attributes

[featured_content image="false" display_author="true" columns="3" showposts="5" order="desc" orderby="title" /]

In this advanced example, the shortcode [featured_content /] is used with custom attributes. The ‘image’ attribute is set to “false”, which means the image of the featured content will not be displayed. The ‘display_author’ attribute is set to “true”, which means the author of the content will be displayed. The ‘columns’ attribute is set to “3”, which means the content will be displayed in 3 columns. The ‘showposts’ attribute is set to “5”, which means only the first 5 posts will be displayed. The ‘order’ attribute is set to “desc”, which means the posts will be displayed in descending order. The ‘orderby’ attribute is set to “title”, which means the posts will be ordered by their title.

PHP Function Code

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

Shortcode line:

add_shortcode( 'featured_content', array( $this, 'featured_content_shortcode' ) );

Shortcode PHP function:

function featured_content_shortcode( $atts ) {
		// Default attributes
		$atts = shortcode_atts(
			array(
				'image'           => true,
				'display_types'   => true,
				'display_tags'    => true,
				'display_content' => true,
				'display_author'  => false,
				'show_filter'     => false,
				'include_type'    => false,
				'include_tag'     => false,
				'columns'         => 2,
				'showposts'       => -1,
				'order'           => 'asc',
				'orderby'         => 'date',
			),
			$atts,
			'featured_content'
		);

		// A little sanitization
		if ( $atts['image'] && 'true' != $atts['image'] ) {
			$atts['image'] = false;
		}

		if ( $atts['display_types'] && 'true' != $atts['display_types'] ) {
			$atts['display_types'] = false;
		}

		if ( $atts['display_tags'] && 'true' != $atts['display_tags'] ) {
			$atts['display_tags'] = false;
		}

		if ( $atts['display_author'] && 'true' != $atts['display_author'] ) {
			$atts['display_author'] = false;
		}

		if ( $atts['display_content'] && 'true' != $atts['display_content'] && 'full' != $atts['display_content'] ) {
			$atts['display_content'] = false;
		}

		if ( $atts['include_type'] ) {
			$atts['include_type'] = explode( ',', str_replace( ' ', '', $atts['include_type'] ) );
		}

		if ( $atts['include_tag'] ) {
			$atts['include_tag'] = explode( ',', str_replace( ' ', '', $atts['include_tag'] ) );
		}

		// Check if column value is set to valid numbers or else set default value as 2
		if ( 1 <= $atts['columns'] && 6 >= $atts['columns'] ) {
			$atts['columns'] = absint( $atts['columns'] );
		} else {
			$atts['columns'] = 2;
		}

		$atts['showposts'] = intval( $atts['showposts'] );

		if ( $atts['order'] ) {
			$atts['order'] = urldecode( $atts['order'] );
			$atts['order'] = strtoupper( $atts['order'] );
			if ( 'DESC' != $atts['order'] ) {
				$atts['order'] = 'ASC';
			}
		}

		if ( $atts['orderby'] ) {
			$atts['orderby'] = urldecode( $atts['orderby'] );
			$atts['orderby'] = strtolower( $atts['orderby'] );
			$allowed_keys    = array( 'author', 'date', 'title', 'rand' );

			$parsed = array();
			foreach ( explode( ',', $atts['orderby'] ) as $featured_content_index_number => $orderby ) {
				if ( ! in_array( $orderby, $allowed_keys ) ) {
					continue;
				}
				$parsed[] = $orderby;
			}

			if ( empty( $parsed ) ) {
				unset( $atts['orderby'] );
			} else {
				$atts['orderby'] = implode( ' ', $parsed );
			}
		}

		// enqueue shortcode styles when shortcode is used
		wp_enqueue_style( 'featured-content-style', plugins_url( 'css/featured-content-shortcode.css', __FILE__ ), array(), '20140326' );

		return self::featured_content_shortcode_html( $atts );
	}

Code file location:

essential-content-types/essential-content-types/admin/class-featured-content.php

Essential Content Types [food_menu] Shortcode

The ‘food_menu’ shortcode from the essential-content-types plugin is designed to display a food menu on your WordPress site. This shortcode accepts three attributes: ‘include_type’, ‘include_tag’, and ‘showposts’. The ‘include_type’ and ‘include_tag’ attributes filter the food items to display based on type and tag. The ‘showposts’ attribute limits the number of food items to display. The shortcode also enqueues the necessary CSS and JS files for proper styling and functionality. The resulting output is generated by the ‘ect_food_shortcode_html’ function.

Shortcode: [food_menu]

Parameters

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

  • include_type – Defines the types of food to include in the menu.
  • include_tag – Specifies the tags related to food items to be included.
  • showposts – Determines the number of food items to display.

Examples and Usage

Basic Example – Displaying the entire food menu without any specific type or tag restrictions.

[food_menu /]

Advanced Examples

Displaying the food menu with a specific type. In this case, the type is ‘vegan’. It will only show food items categorized as ‘vegan’.

[food_menu include_type='vegan' /]

Displaying the food menu with a specific tag. Here, the tag is ‘gluten-free’. It will only show food items tagged as ‘gluten-free’.

[food_menu include_tag='gluten-free' /]

Limiting the number of food items shown in the food menu. This example will show only the first 5 food items.

[food_menu showposts=5 /]

Combining multiple attributes for more specific food menu displays. This example will show the first 3 ‘vegan’ food items that are also tagged as ‘gluten-free’.

[food_menu include_type='vegan' include_tag='gluten-free' showposts=3 /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'food_menu', array( $this, 'ect_food_shortcode' ) );

Shortcode PHP function:

function ect_food_shortcode( $atts ) {
        // Default attributes
        $atts = shortcode_atts( array(
            'include_type'    => false,
            'include_tag'     => false,
            'showposts'       => -1,
        ), $atts, 'food_menu' );

        // A little sanitization
        if ( $atts['include_type'] ) {
            $atts['include_type'] = explode( ',', str_replace( ' ', '', $atts['include_type'] ) );
        }

        if ( $atts['include_tag'] ) {
            $atts['include_tag'] = explode( ',', str_replace( ' ', '', $atts['include_tag'] ) );
        }

        $atts['showposts'] = intval( $atts['showposts'] );

        // enqueue shortcode styles when shortcode is used
        wp_enqueue_style( 'ect-food-menu-style', plugins_url( 'css/food-menu-shortcode.css', __FILE__ ), array(), '20140326' );
        wp_enqueue_script( 'ect-food-menu-script', plugins_url( 'js/food-menu-shortcode.js', __FILE__ ) , array( 'jquery' ), '20180530', false );

        return self::ect_food_shortcode_html( $atts );
    }

Code file location:

essential-content-types/essential-content-types/admin/class-food-menu.php

Essential Content Types [portfolio] Shortcode

The ‘portfolio’ shortcode from the Essential-Content-Types plugin allows users to customize the display of portfolio items on their site. The attributes include options to show/hide types, tags, content, author, and filter. Users can also specify the number of columns, posts, and sorting order.

Shortcode: [portfolio]

Parameters

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

  • display_types – Determines if portfolio types are shown
  • display_tags – Defines if portfolio tags are displayed
  • display_content – Controls if portfolio content is shown
  • display_author – Decides if the author’s name is displayed
  • show_filter – Controls if the portfolio filter is shown
  • include_type – Includes specific portfolio types
  • include_tag – Includes specific portfolio tags
  • columns – Defines the number of columns in the portfolio grid
  • showposts – Determines the number of posts to show
  • order – Specifies the order of the portfolio items
  • orderby – Determines the parameter to order the portfolio items by

Examples and Usage

Basic example – The shortcode displays a portfolio with default settings. This includes displaying types, tags, and content, but not the author, with three columns and an unlimited number of posts ordered by date in descending order.

[portfolio /]

Advanced examples

Displaying a portfolio with specific type and tag, without content, and ordered by title in ascending order. The shortcode also specifies the number of posts to display as 10 and the number of columns as 4.

[portfolio display_content=false include_type="type1,type2" include_tag="tag1,tag2" showposts=10 columns=4 order="ASC" orderby="title" /]

Displaying a portfolio with specific type and tag, including the author, without any filter, and ordered randomly. The shortcode also specifies the number of posts to display as 5 and the number of columns as 2.

[portfolio display_author=true show_filter=false include_type="type1,type2" include_tag="tag1,tag2" showposts=5 columns=2 orderby="rand" /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'portfolio',                                                    array( $this, 'portfolio_shortcode' ) );

Shortcode PHP function:

function portfolio_shortcode( $atts ) {
        // Default attributes
        $atts = shortcode_atts( array(
            'display_types'   => true,
            'display_tags'    => true,
            'display_content' => true,
            'display_author'  => false,
            'show_filter'     => false,
            'include_type'    => false,
            'include_tag'     => false,
            'columns'         => 3,
            'showposts'       => -1,
            'order'           => 'DESC',
            'orderby'         => 'date',
        ), $atts, 'portfolio' );

        // A little sanitization
        if ( $atts['display_types'] && 'true' != $atts['display_types'] ) {
            $atts['display_types'] = false;
        }

        if ( $atts['display_tags'] && 'true' != $atts['display_tags'] ) {
            $atts['display_tags'] = false;
        }

        if ( $atts['display_author'] && 'true' != $atts['display_author'] ) {
            $atts['display_author'] = false;
        }

        if ( $atts['display_content'] && 'true' != $atts['display_content'] && 'full' != $atts['display_content'] ) {
            $atts['display_content'] = false;
        }

        if ( $atts['include_type'] ) {
            $atts['include_type'] = explode( ',', str_replace( ' ', '', $atts['include_type'] ) );
        }

        if ( $atts['include_tag'] ) {
            $atts['include_tag'] = explode( ',', str_replace( ' ', '', $atts['include_tag'] ) );
        }

        // Check if column value is set to valid numbers or else set default value as 2
        if( 1 <= $atts['columns'] && 6 >= $atts['columns'] ) {
            $atts['columns'] = absint( $atts['columns'] );
        } else {
            $atts['columns'] = 2;
        }

        $atts['showposts'] = intval( $atts['showposts'] );


        if ( $atts['order'] ) {
            $atts['order'] = urldecode( $atts['order'] );
            $atts['order'] = strtoupper( $atts['order'] );
            /* if ( 'DESC' != $atts['order'] ) {
                $atts['order'] = 'ASC';
            } */
        }

        if ( $atts['orderby'] ) {
            $atts['orderby'] = urldecode( $atts['orderby'] );
            $atts['orderby'] = strtolower( $atts['orderby'] );
            $allowed_keys = array( 'author', 'date', 'title', 'rand' );

            $parsed = array();
            foreach ( explode( ',', $atts['orderby'] ) as $portfolio_index_number => $orderby ) {
                if ( ! in_array( $orderby, $allowed_keys ) ) {
                    continue;
                }
                $parsed[] = $orderby;
            }

            if ( empty( $parsed ) ) {
                unset( $atts['orderby'] );
            } else {
                $atts['orderby'] = implode( ' ', $parsed );
            }
        }

        // enqueue shortcode styles when shortcode is used
        wp_enqueue_style( 'jetpack-portfolio-style', plugins_url( 'css/portfolio-shortcode.css', __FILE__ ), array(), '20140326' );

        return self::portfolio_shortcode_html( $atts );
    }

Code file location:

essential-content-types/essential-content-types/admin/class-portfolio.php

Essential Content Types [services] Shortcode

The ‘services’ shortcode from Essential Content Types plugin dynamically displays service-related content. It allows customization of displayed attributes including images, types, tags, author, and content. It also includes filters for specific service types or tags. The layout can be altered with adjustable columns and post numbers. It also offers control over the order of services displayed. Shortcode: [services] The shortcode enqueues a specific stylesheet, ensuring consistent styling when the shortcode is used. Shortcode: [services]

Shortcode: [services]

Parameters

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

  • image – Controls if the service image is displayed or not.
  • display_types – Determines if the service types are visible.
  • display_tags – Decides if the service tags are shown.
  • display_content – Controls whether to display the service content.
  • display_author – Decides if the author’s name is displayed.
  • show_filter – Determines if a filter option is provided.
  • include_type – Specifies the types of services to include.
  • include_tag – Specifies the tags of services to include.
  • columns – Sets the number of columns for displaying services.
  • showposts – Determines the number of service posts to show.
  • order – Sets the order of the services, ascending or descending.
  • orderby – Determines the parameter to sort the services by.

Examples and Usage

Basic example – Display services with default attributes

[services]

Advanced examples

Display services without images and author information

[services image=false display_author=false]

Display services with specific types and tags

[services include_type="type1,type2" include_tag="tag1,tag2"]

Display services in 4 columns, ordered by title in descending order

[services columns=4 order="desc" orderby="title"]

Display only 5 services

[services showposts=5]

Display services with full content

[services display_content="full"]

These examples demonstrate the flexibility of the ‘services’ shortcode. You can customize the display of your services based on your specific needs by using different combinations of the available attributes.

PHP Function Code

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

Shortcode line:

add_shortcode( 'services',                                                    array( $this, 'service_shortcode' ) );

Shortcode PHP function:

function service_shortcode( $atts ) {
        // Default attributes
        $atts = shortcode_atts( array(
            'image'           => true,
            'display_types'   => true,
            'display_tags'    => true,
            'display_content' => true,
            'display_author'  => false,
            'show_filter'     => false,
            'include_type'    => false,
            'include_tag'     => false,
            'columns'         => 2,
            'showposts'       => -1,
            'order'           => 'asc',
            'orderby'         => 'date',
        ), $atts, 'services' );

        // A little sanitization
        if ( $atts['image'] && 'true' != $atts['image'] ) {
            $atts['image'] = false;
        }

        if ( $atts['display_types'] && 'true' != $atts['display_types'] ) {
            $atts['display_types'] = false;
        }

        if ( $atts['display_tags'] && 'true' != $atts['display_tags'] ) {
            $atts['display_tags'] = false;
        }

        if ( $atts['display_author'] && 'true' != $atts['display_author'] ) {
            $atts['display_author'] = false;
        }

        if ( $atts['display_content'] && 'true' != $atts['display_content'] && 'full' != $atts['display_content'] ) {
            $atts['display_content'] = false;
        }

        if ( $atts['include_type'] ) {
            $atts['include_type'] = explode( ',', str_replace( ' ', '', $atts['include_type'] ) );
        }

        if ( $atts['include_tag'] ) {
            $atts['include_tag'] = explode( ',', str_replace( ' ', '', $atts['include_tag'] ) );
        }

        // Check if column value is set to valid numbers or else set default value as 2
        if( 1 <= $atts['columns'] && 6 >= $atts['columns'] ) {
            $atts['columns'] = absint( $atts['columns'] );
        } else {
            $atts['columns'] = 2;
        }

        $atts['showposts'] = intval( $atts['showposts'] );


        if ( $atts['order'] ) {
            $atts['order'] = urldecode( $atts['order'] );
            $atts['order'] = strtoupper( $atts['order'] );
            if ( 'DESC' != $atts['order'] ) {
                $atts['order'] = 'ASC';
            }
        }

        if ( $atts['orderby'] ) {
            $atts['orderby'] = urldecode( $atts['orderby'] );
            $atts['orderby'] = strtolower( $atts['orderby'] );
            $allowed_keys = array( 'author', 'date', 'title', 'rand' );

            $parsed = array();
            foreach ( explode( ',', $atts['orderby'] ) as $service_index_number => $orderby ) {
                if ( ! in_array( $orderby, $allowed_keys ) ) {
                    continue;
                }
                $parsed[] = $orderby;
            }

            if ( empty( $parsed ) ) {
                unset( $atts['orderby'] );
            } else {
                $atts['orderby'] = implode( ' ', $parsed );
            }
        }

        // enqueue shortcode styles when shortcode is used
        wp_enqueue_style( 'service-style', plugins_url( 'css/service-shortcode.css', __FILE__ ), array(), '20140326' );

        return self::service_shortcode_html( $atts );
    }

Code file location:

essential-content-types/essential-content-types/admin/class-service.php

Essential Content Types [jetpack_testimonials] Shortcode

The Jetpack Testimonials shortcode is a dynamic tool that displays testimonials on your site. It allows customization of content display, image inclusion, column number, and post order. This shortcode can display full or partial content, include an image or not, and arrange testimonials in 1 or 2 columns. It also provides control over the number of posts shown and their order, sorted by author, date, title, or randomly.

Shortcode: [jetpack_testimonials]

Parameters

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

  • display_content – Controls whether the testimonial content is displayed.
  • image – Determines if an image should be shown with the testimonial.
  • columns – Specifies the number of columns to display the testimonials in.
  • showposts – Indicates the number of testimonials to show.
  • order – Defines the order in which testimonials are displayed, either ascending (ASC) or descending (DESC).
  • orderby – Sets the criteria by which testimonials are sorted (by author, date, title, or randomly).

Examples and Usage

Basic example – A simple use of the jetpack_testimonials shortcode to display testimonials in ascending order by date.

[jetpack_testimonials]

Advanced examples

Displaying testimonials without the image and limiting the number of testimonials shown to 5.

[jetpack_testimonials image=false showposts=5]

Displaying testimonials in 2 columns, ordered randomly, without the full content display.

[jetpack_testimonials columns=2 orderby=rand display_content=false]

Displaying testimonials in descending order by the author, with the image and limiting the number of testimonials shown to 3.

[jetpack_testimonials order=desc orderby=author showposts=3 image=true]

PHP Function Code

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

Shortcode line:

add_shortcode( 'jetpack_testimonials', array( $this, 'jetpack_testimonial_shortcode' ) );

Shortcode PHP function:

function jetpack_testimonial_shortcode( $atts ) {
		// Default attributes
		$atts = shortcode_atts(
			array(
				'display_content' => true,
				'image'           => true,
				'columns'         => 1,
				'showposts'       => -1,
				'order'           => 'asc',
				'orderby'         => 'date',
			),
			$atts,
			'testimonial'
		);

		// A little sanitization
		if ( $atts['display_content'] && 'true' != $atts['display_content'] && 'full' != $atts['display_content'] ) {
			$atts['display_content'] = false;
		}

		if ( $atts['image'] && 'true' != $atts['image'] ) {
			$atts['image'] = false;
		}

		// Check if column value is set to valid numbers or else set default value as 1
		if ( 1 == $atts['columns'] || 2 == $atts['columns'] ) {
			$atts['columns'] = absint( $atts['columns'] );
		} else {
			$atts['columns'] = 1;
		}

		$atts['showposts'] = intval( $atts['showposts'] );

		if ( $atts['order'] ) {
			$atts['order'] = urldecode( $atts['order'] );
			$atts['order'] = strtoupper( $atts['order'] );
			if ( 'DESC' != $atts['order'] ) {
				$atts['order'] = 'ASC';
			}
		}

		if ( $atts['orderby'] ) {
			$atts['orderby'] = urldecode( $atts['orderby'] );
			$atts['orderby'] = strtolower( $atts['orderby'] );
			$allowed_keys    = array( 'author', 'date', 'title', 'rand' );

			$parsed = array();
			foreach ( explode( ',', $atts['orderby'] ) as $testimonial_index_number => $orderby ) {
				if ( ! in_array( $orderby, $allowed_keys ) ) {
					continue;
				}
				$parsed[] = $orderby;
			}

			if ( empty( $parsed ) ) {
				unset( $atts['orderby'] );
			} else {
				$atts['orderby'] = implode( ' ', $parsed );
			}
		}

		// enqueue shortcode styles when shortcode is used
		wp_enqueue_style( 'jetpack-testimonial-style', plugins_url( 'css/testimonial-shortcode.css', __FILE__ ), array(), '20140326' );

		return self::jetpack_testimonial_shortcode_html( $atts );
	}

Code file location:

essential-content-types/essential-content-types/admin/class-testimonial.php

Conclusion

Now that you’ve learned how to embed the Essential Content Types 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 *