Posts Table with Search & Sort Shortcode

Below, you’ll find a detailed guide on how to add the Posts Table with Search & Sort 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 Posts Table with Search & Sort Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Posts Table with Search & Sort Plugin and the shortcodes it provides:

Plugin Icon
Posts Table with Search & Sort

"Posts Table with Search & Sort is a powerful WordPress plugin that allows you to easily organize, search, and sort your blog posts in a structured table format, enhancing the user experience."

★★★★☆ (17) Active Installs: 4000+ Tested with: 6.3.2 PHP Version: 7.1
Included Shortcodes:
  • [Simple_Posts_Table]

Posts Table with Search & Sort [Simple_Posts_Table] Shortcode

The Simple_Posts_Table shortcode is a powerful tool in WordPress. It generates a customizable table of posts. This shortcode parses attributes, creates a table based on them, and returns the output. It uses the ‘do_shortcode’ function to generate the table, allowing you to easily display posts in a structured format.

Shortcode: [Simple_Posts_Table]

Examples and Usage

Basic example – Showcases a simple usage of the shortcode to display a table with a specific ID.

[simple_posts_table id="1" /]

Advanced examples

Displays a table with a specific ID and sets the number of posts per page to 10.

[simple_posts_table id="1" posts_per_page="10" /]

Displays a table with a specific ID, sets the number of posts per page to 10, and sorts the posts by title in ascending order.

[simple_posts_table id="1" posts_per_page="10" orderby="title" order="asc" /]

Displays a table with a specific ID, sets the number of posts per page to 10, sorts the posts by title in ascending order, and includes only posts from the category with ID 2.

[simple_posts_table id="1" posts_per_page="10" orderby="title" order="asc" category="2" /]

PHP Function Code

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

Shortcode line:

add_shortcode( self::SHORTCODE, [ $this, 'do_shortcode' ] );

Shortcode PHP function:

                    function do_shortcode( $atts, $content = '' ) {
		// Parse attributes
		$atts = shortcode_atts( Simple_Posts_Table::get_defaults(), $atts, self::SHORTCODE );

		// Create table and return output
		$table = new Simple_Posts_Table();
		return $table->get_table( $atts );
	}
                    

Code file location:

posts-data-table/posts-data-table/src/Table_Shortcode.php

Conclusion

Now that you’ve learned how to embed the Posts Table with Search & Sort 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 *