Calling table on dynamic page by using page title
-
Hi,
I’m trying to accomplish the following.
I have pages that get dynamically generated with Elementor and I am filling them with content via ACF. Also, I’m loading tables with TablePress in a different part of the website and it works great. So I have tables in my database and listing them on a dedicated page. Great!Now I’d like to use those tables on dynamically generated pages as well.
But to call them dynamically in context with the page being generated, I’d need a short-code for the tables to call the correct table for the page.
The short code should contain a function that looks at the page title it is on and then pull the correct table from the database. All tables are called the same name as the pages titles plus the word “table”: “some-title-table”, “another-title-table” etc.
So in the shortcode the call should be for
PAGE-TITLE-tableIf a table with the name of PAGE-TITLE exists and has content it should show on the according page.
So on a page called:
domain.com/category/some-titlethere should be the table called “some-title-table” visible if the table exists and has content. Otherwise not render the table.
And for
domain.com/category/another-titlethere should be the table called “another-title-table” visible if the table exists and has content. Otherwise not render the table.
I hope I’m making sense here.
Any ideas on how to set up a function in the backend for such a shortcode?Thanks kindly!
- The topic ‘Calling table on dynamic page by using page title’ is closed to new replies.