Creating post tables using a shortcode
The easiest way to create a table with Posts Table Pro is to use the table builder. If you prefer, then you can create tables directly in a shortcode:
[posts_table]
– Generates a new table on the fly, listing posts of the post type set in the plugin settings (defaults to standard posts). You don’t need to create a table in advance.[posts_table_template id="X"]
– Inserts a specific table that you created via Post Tables → Add New in the WordPress admin. ReplaceX
with the ID of the table (visible in the Post Tables list). This will use all the options saved in that table.
If you use the id
parameter, then the table will use the options from the table builder unless you override them with other shortcode options. If you use [posts_table]
without an ID, it will create a table using the default settings (which you can customize on the plugin settings page) or any options you include in the shortcode.
Shortcode options
The Posts Table Pro shortcode supports dozens of optional parameters to control the content and behavior of the table. You can add these to the shortcode as option="value"
pairs, separated by spaces. For example:
[posts_table columns="title,content,button" page_length="false" sort_by="title"]
Below is a full list of available shortcode options, along with their usage and examples.
Table columns
The columns
shortcode option specifies which columns to include in the table and their order.
The available columns are: id
, title
, content
, excerpt
, image
, date
, date_modified
, author
, categories
, tags
, status
, button
, or any custom field or taxonomy. These column names are case sensitive and should always be lower case.
Example:
[posts_table columns="image,title,content,date,author"]
Custom field columns
You can display custom field values as table columns using cf:field_name
, replacing "field_name" with the meta key of the custom field.
Example:
[posts_table columns="title,cf:price,cf:location"]
Custom taxonomy columns
To display custom taxonomy terms, use tax:taxonomy_slug
. Replace "taxonomy_slug" with the actual taxonomy name.
Example:
[posts_table columns="title,content,tax:company,tax:team"]
Renaming column headings
To rename a column heading, add :New Heading
after the column name.
Example:
[posts_table columns="title:Article Name,cf:price:Cost,tax:genre:Category"]
Hiding column names
To remove a column heading completely, use the keyword blank
after the colon.
Example:
[posts_table columns="title:blank,content,categories"]
When you do this, the column names will be removed and only the sort arrows will be hidden. If you want to hide the header row completely then you can do this using header="false"
(see below).
Combined columns
To merge multiple columns into a single columns, list the column names in brackets. To set a name for each sub-column, add a semi-colon after the column name followed by the label (you should still use commas to separate normal, non-combined columns).
For example, the shortcode[posts_table columns="image,(title;categories:Cat:,tags:Tag):Combined Heading"]
will create the following columns:
- Image
- Combined column with a heading of "Combined Heading", consisting of:
- Title
- Categories (with the label "Cat")
- Tags (with the label "Tag")
Customizing table content
links
- Controls which columns can be clicked on to access the single post page. Options:all
(enable links on all possible columns)none
orfalse
(disable all links),id
,image
,title
,author
,categories
,tags
,terms
.
Example:[posts_table links="title,terms"]
rows_per_page
- Controls the number of posts on each page of the table. Set to-1
to display all posts on 1 page.
Example:[posts_table rows_per_page="10"]
post_limit
- Sets the maximum number of posts in the entire table. Only used when lazy load is disabled, defaults to 500.widths
– Sets custom widths for each column. Enter a value for each column in your table – either a percentage, a pixel amount orauto
to have the plugin calculate the width automatically.
Example:[posts_table columns="title,content,date" widths="20%,50%,30%"]
content_length
– Limits the number of words in thecontent
column. Default is 15 words, enter -1 to show the full content.
Example:[posts_table content_length="10"]
excerpt_length
– Limits the number of words in theexcerpt
column. Default is 55 words.
Example:[posts_table excerpt_length="30"]
image_size
– Sets the size of images in theimage
column. Default is70x70
pixels.
Examples:- Square image 50 by 50 pixels:
[
posts_table columns="image,title,content" image_size="50"]
- Image 40 pixels wide by 60 pixels high:
[posts_table columns="
image,title,content" image_size="40x60"] - To use the
medium
image size:[posts_table columns="image,title,content" image_size="medium"]
- Square image 50 by 50 pixels:
lightbox
– Enables or disables the lightbox for images. Default istrue
, disable by setting tofalse
.
Example:[posts_table lightbox="false"]
button_text
– Changes the text used for thebutton
column. Default is "View".
Example:[posts_table columns="title,button" button_text="Read More"]
date_columns
- Specify which columns in the table should be treated as dates.
Example:[posts_table columns="image,title,cf:date,tax:custom_tax" date_columns="cf:date,tax:custom_tax"]
date_format
- Tells the table how to format the date column.
Example:[posts_table date_format="F j, Y"]
shortcodes
– Determines whether to render shortcodes and HTML inside the table content. Default isfalse
.
Example:[posts_table shortcodes="true"]
Selecting which posts to display
post_type
– Specifies the post type(s) to include in the table. Defaults topost
.
Example:[posts_table post_type="page"]
category
– Displays posts from specific categories.
Example:[posts_table category="news"]
tag
– Displays posts with specific tags.
Example:[posts_table tag="tutorial"]
term
– Filters posts by specific terms in custom taxonomies.
Example:[posts_table term="genre:fiction"]
cf
– Lists posts with a specific custom field value.
Example:[posts_table cf="field_name:value"]
status
– Displays posts with a specific status. Options:publish
,draft
,pending
,future
,private
orany
.
Example:[posts_table status="draft"]
year
– Displays posts published in a specific year.
Example:[posts_table year="2025"]
month
– Displays posts published in a specific month.
Example:[posts_table month="5"]
Tip: We've also provided a code snippet for developers to list posts from the current month only.day
– Displays posts published on a specific day of the month.
Example:[posts_table day="15"]
author
– Displays posts by a specific user ID.
Example:[posts_table author="1"]
include
– Displays only the specific posts with the given IDs.
Example:[posts_table include="45,67,90"]
exclude
– Excludes specific posts by ID.
Example:[posts_table exclude="123"]
exclude_category
– Excludes entire categories of posts from the table.
Example:[posts_table exclude_category="uncategorized"]
exclude_term
– Excludes posts with specific taxonomy terms from the table.
Example:[posts_table exclude_term="genre:non-fiction"]
mime_type
– Lists media library files with a specific file extension.
Example:[posts_table mime_type="application/pdf"]
Usage tips:
- Custom post type categories - In WordPress, custom post type 'categories' are actually custom taxonomies. As a result, you should use the 'term' shortcode option to display custom posts by category, and not the 'category' option.
- Using AND/OR logic - When specifying multiple items to display, you can either separate them using columns or a plus sign (+). If you use commas it means “posts in this Category A or Category B”. If you use a plus, it means “posts in Category A and Category B”. For example:
- To display posts which are in the “design” category or in the “print” category, use:
[posts_table category="design,print"]
- To display posts which are in the “design” category and in the “print” category, use:
[posts_table category="design+print"]
- To display posts which are in the “design” category or in the “print” category, use:
- Custom fields added using the Toolset plugin - If you're using Toolset to create your custom fields, then you need slightly different syntax to display them in the table. Toolset adds wpcf- to the start of the custom field name, so if you create a custom field called 'color' with a value of 'blue' then the correct syntax will be
wpcf-color:blue
. This means that if you want to create a table displaying posts with a custom field value of 'blue' then you would need to add it as follows:
[posts_table cf="cf:wpcf-color:blue"]
Sorting & ordering
sort_by
– Sets the default sort column for the table when it first loads. Default isdate
(newest first). Choose fromid
,title
,menu_order
,date
,name
,modified
,author
,comment_count
, orrand
for random order.
Example:[posts_table sort_by="title"]
sort_order
– Sets the initial sort direction. Default isasc
for text anddesc
for dates.
Example:[posts_table sort_order="asc"]
Search & filtering
search_box
– Controls the visibility of the search box. Options:top
(default),bottom
,both
, orfalse
.
Example:[posts_table search_box="bottom"]
search_term
– Filters the table by an initial search term when it first loads.
Example:[posts_table search_term="summer"]
search_on_click
– Controls what happens when a user clicks on a taxonomy term or author name. Default isfalse
(goes to archive page), change it totrue
to allow users to filter the table instead.
Example:[posts_table search_on_click="true"]
filters
– Adds dropdown filters for taxonomy columns (categories, tags, or custom taxonomies).
Example:[posts_table filters="categories,tax:genre"]
Renaming filters
You can set custom filter names by adding a : (colon) after the filter name in the shortcode and then entering your custom wording.
Example:
[posts_table filters="categories:Region,tax:sector:Location"]
Pagination & navigation
pagination
– Controls where pagination controls appear. Options:top
,bottom
(default),both
, orfalse
.
Example:[posts_table pagination="false"]
paging_type
– Determines the style of pagination controls. Options:numbers
,simple
,simple numbers
,full
,full numbers
.
Example:[posts_table paging_type="full_numbers"]
page_length
– Controls the number of posts displayed per page. Options:top
(default),bottom
,both
, orfalse
.
Example:[posts_table page_length="25"]
totals
- Whether to display the total number of posts in the table (e.g. “Showing 1 to 10 of 50 entries”), and where to display it. Options:top
,bottom
(default),both
, andfalse
.reset_button
- Whether to display the ‘Reset’ button above the table. Defaults totrue
- change it tofalse
to hide the button.sticky_header
- Make the table header stick as the user scrolls down. Options:true
andfalse
(default).hide_header
- Remove the header row of the table. Options:true
andfalse
(default).show_footer
- Whether or not to show the column headings at the bottom of the table as well as the top. The default isfalse
(i.e. hide the footer headings) and you can set this totrue
to show them.scroll_offset
– Adjusts the scroll position when paginating. Default is15
pixels.
Example:[posts_table scroll_offset="50"]
Responsive & mobile behavior
priorities
- Controls the order in which columns are hidden when there are too many to fit onto the page. Enter a number for each columns, and those with the highest numbers will be hidden last.
Example:[posts_table columns="title,author,categories" priorities="1,3,2"][/no_shortcodes]
responsive_visibility
– Specifies which screen sizes should display each column. See the full list of options in the DataTables documentation.
Example:[posts_table columns="title,date,content" responsive_visibility="all,not-mobile,default"]
responsive_control
– Determines the position of the expand/collapse button for hidden columns. Options:inline
(default) orcolumn
.
Example:[posts_table responsive_control="column"]
responsive_display
– Controls how hidden data is displayed on smaller screens. Options:child_row
(default),child_row_visible
,modal
.
Example:[posts_table responsive_display="modal"]
wrap
– Controls whether text wraps in table cells. Default istrue
, disable by setting tofalse
.
Example:[posts_table wrap="false"]
Performance options
lazy_load
– Enables AJAX-based lazy loading for large tables. Default isfalse
.
Example:[posts_table lazy_load="true"]
cache
– Enables or disables caching of the table’s data. Default isfalse
.
Example:[posts_table cache="true"]
Custom messages
no_posts_message
– Custom message displayed when no posts match the query.
Example:[posts_table no_posts_message="Sorry, no posts found."]
no_posts_filtered_message
– Custom message displayed when filtering results in no matches.
Example:[posts_table no_posts_filtered_message="No posts match your search."]