Themify Portfolio Post Shortcode

Below, you’ll find a detailed guide on how to add the Themify Portfolio Post Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Themify Portfolio Post Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Themify Portfolio Post Plugin and the shortcodes it provides:

Plugin Icon
Themify Portfolio Post

"Themify Portfolio Post is a powerful WordPress plugin that allows users to effortlessly create, manage, and showcase their professional portfolios, enhancing their online presence."

★★★★★ (1) Active Installs: 40000+ Tested with: 6.2.3 PHP Version: false
Included Shortcodes:
  • [themify_portfolio_posts]

Themify Portfolio Post [themify_portfolio_posts] Shortcode

The Themify Portfolio Posts shortcode is designed to fetch and display portfolio posts on your site. It allows customization of post attributes, including the title, image, post meta, date, and more. You can also control the number of posts displayed, their order, and categorization. It supports pagination and provides an option to filter entries. The style of the grid can be set to grid2, grid3, or grid4.

Shortcode: [themify_portfolio_posts]

Parameters

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

  • id – Identifies the specific portfolio post.
  • title – Determines if the title is displayed.
  • unlink_title – Decides if the title is clickable.
  • image – Controls if the image is shown.
  • unlink_image – Decides if the image is clickable.
  • image_w – Sets the width of the image.
  • image_h – Sets the height of the image.
  • display – Chooses between displaying the excerpt or the content.
  • post_meta – Determines if post metadata is shown.
  • post_date – Controls if the post date is displayed.
  • more_text – Sets the text for the “read more” link.
  • limit – Sets the number of posts displayed.
  • category – Filters posts by category ID.
  • order – Sets the order of the posts.
  • orderby – Determines what parameter the posts are ordered by.
  • style – Defines the grid style of the posts.
  • paged – For internal use, sets the pagination.
  • filter – Determines if an entry filter is used.
  • pagination – Controls if pagination is shown.

Examples and Usage

Basic example – Showcases a portfolio post with default parameters.

[themify_portfolio_posts /]

Advanced examples

Displaying a portfolio post with a specific ID, the title linked, and an image unlinked.

[themify_portfolio_posts id="1" title="yes" unlink_title="no" image="yes" unlink_image="yes" /]

Displaying a portfolio post with a specific category, ordered by title in ascending order, and with a limit of 6 posts.

[themify_portfolio_posts category="design" order="ASC" orderby="title" limit="6" /]

Displaying a portfolio post in a grid of 3, without pagination, and without the entry filter.

[themify_portfolio_posts style="grid3" pagination="no" filter="no" /]

Displaying a portfolio post with a custom “More” text, without post date, and without post meta.

[themify_portfolio_posts more_text="Read More" post_date="no" post_meta="no" /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'themify_portfolio_posts', array( $this, 'shortcode' ) );

Shortcode PHP function:

function shortcode( $atts, $content = '' ) {
		$atts = shortcode_atts( array(
			'id' => '',
			'title' => 'yes',
			'unlink_title' => 'no',
			'image' => 'yes', // no
			'unlink_image' => 'no',
			'image_w' => 290,
			'image_h' => 290,
			'display' => 'excerpt', // excerpt, content
			'post_meta' => 'yes', // no
			'post_date' => 'yes', // no
			'more_text' => __( 'More →', 'themify-portfolio-post' ),
			'limit' => 4,
			'category' => '', // integer category ID
			'order' => 'DESC', // ASC
			'orderby' => 'date', // title, rand
			'style' => 'grid4', // grid4, grid3, grid2
			'paged' => '0', // internal use for pagination, dev: previously was 1
			'filter' => 'no', // entry filter
			'pagination' => 'yes',
		), $atts, 'themify_portfolio_posts' );
		extract( $atts );

		// Pagination
		global $paged;
		$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
		// Parameters to get posts
		$args = array(
			'post_type' => 'portfolio',
			'posts_per_page' => $limit,
			'order' => $order,
			'orderby' => $orderby,
			'suppress_filters' => false,
			'paged' => $paged
		);

		// Category parameters
		if ( ! empty( $category ) ) {
			$args['tax_query'] = $this->parse_category_args( $category );
		}

		// Get posts according to parameters
		$query = new WP_Query();
		$posts = $query->query( apply_filters( 'themify_portfolio_posts_query', $args, $atts ) );

		$output = '';
		if( $query ) {
			$output = $this->get_template( 'shortcode.php', compact( 'query', 'posts', 'atts' ) );
		}

		return $output;
	}

Code file location:

themify-portfolio-post/themify-portfolio-post/includes/system.php

Conclusion

Now that you’ve learned how to embed the Themify Portfolio Post Plugin shortcode, 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 *