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:
"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."
- [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.
Leave a Reply