Title: Register Shortcode in Functions for Custom Posts
Last modified: December 4, 2019

---

# Register Shortcode in Functions for Custom Posts

 *  Resolved [tim_marston](https://wordpress.org/support/users/tim_marston/)
 * (@tim_marston)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/register-shortcode-in-functions-for-custom-posts/)
 * Hello
 * On our website, we not only use the standard WP posts, but we also have four 
   custom type posts for our content.
 * Because the tables do not pull through to the custom post types, I would like
   to register the shortcode in our custom theme functions file.
 * I noticed and read in your documentation on your own site where you have the 
   query instructions to add to the theme files. That would work, but our problem
   is if we use that method of output, the chart would have to fall in the same 
   place in every custom post. The line would be dictated by where I place it in
   the theme file.
 * I would prefer to register the shortcode in functions.php so that it would work
   in the custom theme wherever we choose to put the shortcode in the content.
 * Also, the shortcode needs to output the correct table, as every post would have
   a different table.
 * Could you please help in letting me know which “add shortcode” to put in the 
   theme’s function.php.
 * Thank you so much

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/register-shortcode-in-functions-for-custom-posts/#post-12206160)
 * Hi,
 * thanks for your post, and sorry for the trouble.
 * You shouldn’t actually need any special handling regarding Shortcodes in your
   CPT posts. All that normally is required is proper usage of the `the_content();`
   template tag in your theme, inside the WordPress “Loop” that loads your posts.
   Are you maybe using something like `$post->post_content;` there to echo the post
   content?
 * Regards,
    Tobias
 *  Thread Starter [tim_marston](https://wordpress.org/support/users/tim_marston/)
 * (@tim_marston)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/register-shortcode-in-functions-for-custom-posts/#post-12206385)
 * When we put this in the theme file, the table outputs perfectly
 * echo do_shortcode(“[table id=2 /]”);
 * But when we use the actual shortcode in the custom post
 * [table id=2 /]
 * We get only the shortcode and not the table.
 * All of the commands in the theme file start with “echo”.
 * The content seems to be called up like this
 * get_template_part( ‘template-parts/content’, ‘howtopost’ );
 * and later, it when the php ends, it does say “end of loop”
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/register-shortcode-in-functions-for-custom-posts/#post-12207763)
 * Hi,
 * ok, this means the relevant code should be in a file “template-parts/content”
   or similar in your theme. Can you maybe check that? It needs to have a call for`
   the_content()`.
 * Regards,
    Tobias
 *  Thread Starter [tim_marston](https://wordpress.org/support/users/tim_marston/)
 * (@tim_marston)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/register-shortcode-in-functions-for-custom-posts/#post-12210132)
 * I hope this is the part you are looking for. And thanks again for trying to help
   with this. Your support on the plugin is phenomenal.
 * <?php
    if ( ( is_singular() || ‘content’ == $bavotasan_theme_options[‘excerpt_content’])&&‘
   main’ == $mb_content_area && ! is_archive() && ! is_search() ) { the_content(
   __( ‘Read more →’, ‘magazine-basic’ ) ); } else {
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/register-shortcode-in-functions-for-custom-posts/#post-12211183)
 * Hi,
 * this looks ok to me. Shortcodes should be evaluated with this…
 * Unfortunately, I’m out of ideas here then. Can you maybe try again after temporarily
   deactivating all other plugins and after switching to a WordPress default theme
   like Twenty Twenty? That way, we can find out if something is interfering.
 * Regards,
    Tobias
 *  Thread Starter [tim_marston](https://wordpress.org/support/users/tim_marston/)
 * (@tim_marston)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/register-shortcode-in-functions-for-custom-posts/#post-12217036)
 * Hey man, sorry for the late reply, we found a work around. Thanks for your amazing
   support
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/register-shortcode-in-functions-for-custom-posts/#post-12217433)
 * Hi,
 * great! That’s good to hear 🙂
 * Best wishes,
    Tobias

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Register Shortcode in Functions for Custom Posts’ is closed to new replies.

 * ![](https://ps.w.org/tablepress/assets/icon.svg?rev=3192944)
 * [TablePress - Tables in WordPress made easy](https://wordpress.org/plugins/tablepress/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/tablepress/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/tablepress/)
 * [Active Topics](https://wordpress.org/support/plugin/tablepress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/tablepress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/tablepress/reviews/)

## Tags

 * [Table Press](https://wordpress.org/support/topic-tag/table-press/)

 * 7 replies
 * 2 participants
 * Last reply from: [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * Last activity: [6 years, 6 months ago](https://wordpress.org/support/topic/register-shortcode-in-functions-for-custom-posts/#post-12217433)
 * Status: resolved