How to use the post table layout on the general WordPress search results page
Posts Table Pro has several built-in search options: a search box above the table, and a standalone search box. In addition, it is possible to display the Posts Table Pro layout on your sitewide search results page. This is the search results page which appears when people use the 'Search' widget this is part of WordPress itself.
This is outside of the standard usage of Posts Table Pro and requires modifying the search template in your theme, which is a developer-level task.
This article contains general advice about how to display the search results from the built-in WordPress search in a table. This is advanced usage of Posts Table Pro and isn't covered by our standard plugin support.
How to display WordPress search results in a table
We have created a sample search.php file to get you started. This is designed to work with the Storefront theme, and the exact code for your theme will differ from this. If you don't know how to adapt it to your own theme, then you will need to ask your developer.
In this file you will see the following line:
add_filter( 'posts_table_run_in_search', '__return_true' );
This ensures that the posts table will work on the search results page.
You will then see a call to the
ptp_the_posts_table function. This displays the table using the posts from the current search. You could also add extra options here, passing these to the
ptp_the_posts_table. This function takes the same attributes and options as the posts table shortcode.
The exact implementation will depend on your theme. You will most likely need to modify the HTML structure to match the other templates in your theme.
Customizing the posts table in the search results
The example file includes a table with the default columns and options set in the plugin settings. Any additional shortcode options can be passed as arguments in the array given to the call to
ptp_the_posts_table. Please see the complete list of Posts Table options.
The wrong number of posts are showing in the results!
When you add the Posts Table Pro layout to the search results template, the maximum number of results is set by the global WordPress settings under Settings → Reading. You can increase or change the number of possible results by editing this number.
Since this is advanced usage of the plugin, it's not covered by our standard support. If you don't have a developer and need any help getting it working, we recommend posting a job on Codeable and their WordPress experts will send you a quote. We have partnered with them to provide plugin customizations for our customers.
Can I use Posts Table Pro with third party search plugins?
You can use Posts Table Pro with third party search plugins such as Relevanssi or SearchWP that work by improving the native WordPress search. Integrate them with Posts Table Pro using the same method as we have described above.
If you are using a search plugin that provides its own search results template - instead of using the native WordPress search results - then you would need to modify that template to use the table layout. Again, this is a developer-level task.