Title: Shortcode breaks HTML
Last modified: September 29, 2023

---

# Shortcode breaks HTML

 *  Resolved [IdeFixx](https://wordpress.org/support/users/idefixx/)
 * (@idefixx)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/shortcode-breaks-html/)
 * Hello.
 * I ran into an issue with the shortcode inserted in Twenty Twenty-Three theme.
   This shortcode block works fine in the theme part:
 *     ```wp-block-code
       [post_coauthors]
       ```
   
 * Here is its code from the child’s theme functions.php:
 *     ```wp-block-code
       add_shortcode( 'post_coauthors', 'myshortcode_coauthor' );
       function myshortcode_coauthor() {
       return coauthors_links();
       }
       ```
   
 * But it also breaks the structure of an HTML document:
 *     ```wp-block-code
       <html>
       <head></head> - empty
       <body>
       <a>author's name and link</a> - first time here
       <meta> - all header tags are here
       <main>
       <div class="wp-block-group">
       <a>author's name and link</a> - secondly here
       ```
   
 * As you can see:
    1. HTML head content is shifted to <body>
    2. Content of the shortcode is displayed twice
 * Even if I try to disable all other plugins it does not help. The HTML structure
   is still broken. Co-Authors Plus Troubleshooting Mode does not help either, it
   just activates parent theme without the shortcode.
 * I’ll be glad for any suggestions or ideas on how can I fix it. Thank you.
 * WP Version 6.3.1
   Co-Authors Plus Version 3.5.15Twenty Twenty-Three Version: 1.2

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

 *  Thread Starter [IdeFixx](https://wordpress.org/support/users/idefixx/)
 * (@idefixx)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/shortcode-breaks-html/#post-17089914)
 * Probably it’s related to this pull request [https://github.com/Automattic/Co-Authors-Plus/pull/997](https://github.com/Automattic/Co-Authors-Plus/pull/997)
 *  Plugin Contributor [Gary Jones](https://wordpress.org/support/users/garyj/)
 * (@garyj)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/shortcode-breaks-html/#post-17090182)
 * That PR hasn’t been merged yet, so unless you’re running that PR’s branch (unlikely),
   then it’s not that.
 * The default behaviour of the `coauthors_links()` function is to echo immediately,
   which doesn’t work for what you need with shortcodes.
 * Try:
 *     ```wp-block-code
       add_shortcode( 'post_coauthors', 'myshortcode_coauthor' );
       function myshortcode_coauthor() {
           return coauthors_links(null, null, null, null, false);
       }
       ```
   
 *  Thread Starter [IdeFixx](https://wordpress.org/support/users/idefixx/)
 * (@idefixx)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/shortcode-breaks-html/#post-17090318)
 * Thank you very much for your help. Your shortcode works.

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

The topic ‘Shortcode breaks HTML’ is closed to new replies.

 * ![](https://ps.w.org/co-authors-plus/assets/icon-256x256.png?rev=2945095)
 * [Co-Authors Plus](https://wordpress.org/plugins/co-authors-plus/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/co-authors-plus/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/co-authors-plus/)
 * [Active Topics](https://wordpress.org/support/plugin/co-authors-plus/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/co-authors-plus/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/co-authors-plus/reviews/)

## Tags

 * [blocks](https://wordpress.org/support/topic-tag/blocks/)
 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)

 * 3 replies
 * 2 participants
 * Last reply from: [IdeFixx](https://wordpress.org/support/users/idefixx/)
 * Last activity: [2 years, 8 months ago](https://wordpress.org/support/topic/shortcode-breaks-html/#post-17090318)
 * Status: resolved