Support » Plugin: TablePress » Not working with theme files

  • Resolved Mohsin

    (@mohsin786)


    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

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    Due to how Shortcodes work, they are indeed only evaluated in normal post/page content fields, but not inside theme files. There, you’ll have to use WordPress template tag functions. For TablePress, the available ones are listed at https://tablepress.org/faq/documentation-template-tag-functions/

    You’ll likely want to use something like

    <?php tablepress_print_table( array( 'id' => '123' ) ); ?>
    

    Regards,
    Tobias

    Thread Starter Mohsin

    (@mohsin786)

    Thanks. It works 🙂

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    no problem, you are very welcome! 🙂 Good to hear that this helped!

    Best wishes,
    Tobias

    P.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.