Posts table column widths
Posts Table Pro automatically sizes the columns for the best fit. There are several options to override this behavior to control the column widths, as well as the image sizes in the table.
This is a way to force more or less space for specific columns. For example, you can increase the width of the Content column if there is a lot of content to display.
You can either set widths in the table builder or directly in the [posts_table]
shortcode.
How to force column widths to a certain size
- Go to Post Tables and either create a new table or edit an existing one.
- Click the pencil icon for the column that you wish to edit the width of.
- Enable the 'Advanced' toggle.
- Set the width as follows:
- % - Enter the percentage of the table width that the column should take up. If you enter this for all columns then the total must be 100.
- px - Enter the number of pixels wide that the column should be. If you enter this for all columns then the total must be the same or less than the total available space. Generally, we recommend using the percentage option because it gives more reliable results on different screen sizes.
Shortcode option
To override the default column widths, use the widths
option. You need to enter a value for each column in your table – either a percentage, a pixel amount or the word auto
to have the plugin calculate the width automatically.
For example, you might have 3 columns in your table: title
, content
and date
- and you want to set the width of the title column to 20%, the content column to 50% and the date column to 30%.
You can achieve this with the following shortcode:[posts_table columns="title,content,date" widths="20%,50%,30%"]
In the next example, we want to set the width of the first column to 50px and automatically size the other columns. We would use:
[posts_table columns="title,content,date" widths="50px,auto,auto"]
As auto
is the default column width when no value is given, the above example can be simplified to the following:
[posts_table columns="title,content,date" widths="50px"]
Common problems
The widths option isn't working
If the widths option isn't working, then it might be that you have set the width too narrow and the contents will no longer fit in the column. Instead of allowing it to look broken, the plugin will make the width wider so that the contents fit. Try increasing the width of the affected columns.
I have multiple tables on the same page and I want them all the to line up
The column widths are calculated for each table individually. If you have more than one table on a page, you can use the Widths option to force the widths to be the same for each table by giving each table the same width.
My column widths change when I move from one page to the next, or use the filters
This can happen if the contents of a column contains a different number of characters for each post. The width of each column of the table is calculated based on the current posts on that page, so this might change when you perform a filter or go from one page to the next. Use the Widths option to force the columns to always be the same width.