Title: Homepage shortcode
Last modified: August 12, 2022

---

# Homepage shortcode

 *  [allanjardine](https://wordpress.org/support/users/allanjardine/)
 * (@allanjardine)
 * [3 years, 9 months ago](https://wordpress.org/support/topic/homepage-shortcode/)
 * I’m trying to write a plugin that makes use of shortcodes, and that seems to 
   work okay I’m simply using:
 *     ```
       add_shortcode('allan', function() {
         return 'ALLAN';
       });
       ```
   
 * To test, I’ve been using the [Docker WordPress image](https://hub.docker.com/_/wordpress)(
   currently 6.0.1). Everything default with my plugin installed and the shortcode
   registered.
 * Editing the default post and going to `http://localhost/2022/08/10/hello-world/`
   the shortcode renders out perfectly.
 * On the index page however, I’ve found that:
    - Theme – Twenty Twenty Two: Doesn’t render at all
    - Theme – Twenty Twenty One: Doesn’t render at all
    - Theme – Twenty Twenty: Does render correctly
 * Is there any way to get the default themes to render shortcodes in their index
   pages?
 * I got utterly confused by this and it took me a good while to figure out what
   was going on, and I can only imagine non-techies would be even more frustrated.
    -  This topic was modified 3 years, 9 months ago by [t-p](https://wordpress.org/support/users/t-p/).
      Reason: Moved to Fixing WordPress from Developing with WordPress

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

 *  Moderator [t-p](https://wordpress.org/support/users/t-p/)
 * (@t-p)
 * [3 years, 9 months ago](https://wordpress.org/support/topic/homepage-shortcode/#post-15912134)
 * WordPress documentation has a [Plugin Handbook](https://developer.wordpress.org/plugins/)
 * Also [https://developer.wordpress.org/plugins/wordpress-org/plugin-developer-faq/](https://developer.wordpress.org/plugins/wordpress-org/plugin-developer-faq/)
 *  Thread Starter [allanjardine](https://wordpress.org/support/users/allanjardine/)
 * (@allanjardine)
 * [3 years, 9 months ago](https://wordpress.org/support/topic/homepage-shortcode/#post-15912195)
 * Thanks for the links. I’m not having problems with creating or submitting a plug-
   in, but specifically with shortcodes not bring rendered on the index page for
   the two newest default themes. As I say, they work fine when going to the post’s
   actual page, but not on the index page.
 * From the plug-in handbook you linked to there is a [complete short code example](https://developer.wordpress.org/plugins/shortcodes/shortcodes-with-parameters/#complete-example).
 * Here is the code for the post where I’m using the short code from that example:
 *     ```
       <pre><code><!-- wp:paragraph -->
       <p>wporg should follow this: [wporg]</p>
       <!-- /wp:paragraph -->
   
       <!-- wp:paragraph -->
       <p>Fin</p>
       <!-- /wp:paragraph -->
       ```
   
    - [This is what it looks like on the post’s page](https://pasteboard.co/QS69wYR07nW7.png)
    - [And this is what it looks like on the index page](https://pasteboard.co/IhOtwtA7ggD6.png)
 * As you will be able to see, the shortcode is not rendered, it is simply removed.
   I don’t see anything in the handbook or the FAQs which covers this.
    -  This reply was modified 3 years, 9 months ago by [allanjardine](https://wordpress.org/support/users/allanjardine/).
      Reason: Clarity of post code
 *  Thread Starter [allanjardine](https://wordpress.org/support/users/allanjardine/)
 * (@allanjardine)
 * [3 years, 9 months ago](https://wordpress.org/support/topic/homepage-shortcode/#post-15915317)
 * It looks like this behaviour is intentional. WordPress [will automatically create an extract](https://wordpress.org/support/article/excerpt/)
   for a post that doesn’t have a custom extract, and that automatic extract strips
   shortcodes.
 * I found this exceptionally confusing and it doesn’t appear to be documented anywhere.
   I’ve submitted a note on the documentation page linked above. What really confused
   me is that this changes between themes.

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

The topic ‘Homepage shortcode’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [allanjardine](https://wordpress.org/support/users/allanjardine/)
 * Last activity: [3 years, 9 months ago](https://wordpress.org/support/topic/homepage-shortcode/#post-15915317)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
