-
Table shortcode not working with theme files
-
Hi,
The shortcode for wp table working well with the posts but whenever I try to paste in the theme files (e.g. content-single.php), the table did not showing in the post instead the shortcode is showing in the post.
Is it not compatible with the theme files?
What could be the reason and solution?
Waiting for positive response,
Thanks in advance
-
Hello Mohsin,
For any kind of shortcode to be displayed on front-end, they should be executed within WordPress. Posts objects do this automatically, but if you want this functionality to be executed and parsed on other files, you should specifically call WordPress shortcode parse and execute functions by yourself and handle the results.
Best regards.
-
But is there any template tag regarding the same like Table Press plugin author gives me the below Template tag to add the tables in the template files.
So is there any related template tag for the same to add WP Table Builder Tables in theme files.
<?php tablepress_print_table( array( 'id' => '123' ) ); ?>
-
Can you please try
<?php echo do_shortcode('[wptb id=95]'); ?>
Change the id part with the table id you are trying to display.
Best regards.
-
-
We are glad it is solved. Your support request actually gave us an idea to provide a much simpler method for users to implement this short-code operation for theme files and anywhere else where short-code parsing is not executed automatically. Hoping to release it for further versions.
Best regards.
-
-
-
-
-
For future reference, a global PHP function (
wptb_render_table($table_id)
) is added to plugin files for users to use their created tables within WordPress theme files with ease. This functionality will be available with the next update (1.3.4)-
Great to here that and it will be helpful for the users like me who wants to execute the shortcode within theme files.
Good luck 🙂
-
Log in to reply.