Wordpress shortcode doesn't working on HomePage

admin2025-01-08  5

What I want to do is make my Home Page. I can do it this way:

  1. Create a page and insert my gallery from plugin with that code [wonderplugin_gridgallery id=1]

  2. Set that page as HomePage.

BUT THAT IS NOT WORKING. When I add this code [wonderplugin_gridgallery id=1] to my page, I can see only code… The same doesn't work <?php echo do_shortcode('[wonderplugin_gridgallery id=1]'); ?> (hidden).

How to fix it? I don't know how to find the file to fix in FTP. Themes Virtue.

I hope you understand what I am writing about. Thank you in advance.

What I want to do is make my Home Page. I can do it this way:

  1. Create a page and insert my gallery from plugin with that code [wonderplugin_gridgallery id=1]

  2. Set that page as HomePage.

BUT THAT IS NOT WORKING. When I add this code [wonderplugin_gridgallery id=1] to my page, I can see only code… The same doesn't work <?php echo do_shortcode('[wonderplugin_gridgallery id=1]'); ?> (hidden).

How to fix it? I don't know how to find the file to fix in FTP. Themes Virtue.

I hope you understand what I am writing about. Thank you in advance.

Share Improve this question asked Dec 29, 2018 at 9:06 Sergey KizievSergey Kiziev 311 silver badge6 bronze badges 3
  • This is code for a plugin make sure you have plugin added and activated – Pratik bhatt Commented Dec 29, 2018 at 9:55
  • @Pratikbhatt, Yes activated. In file front-page.php it's written there <?php $post_id_286 = get_post( 286 ); echo $post_id_286->post_content; ?> this is for the main page (homepage). It turned out there does not work shortcode. The post works, the main page is not. You understand? – Sergey Kiziev Commented Dec 29, 2018 at 10:06
  • Your theme should output content with the_content() function, the attached filters are what properly process the output to make shortcodes work. – Milo Commented Dec 29, 2018 at 16:25
Add a comment  | 

2 Answers 2

Reset to default 0

Depending on what post editor you are using:

  • Classic - make sure to switch the editor to "Text" instead of "Visual". The latter will output anything you write in a form of text, while the first one will process the shortcode.
  • Gutenberg - find a plus sign in the top-left area of your WordPress dashboard and add a "Shortcode" block.

If you add the shortcode manually to the file, make sure it's before the closing PHP tag: ?>

If you have the following code in your template:

<?php $post_id_286 = get_post( 286 ); echo $post_id_286->post_content; ?>

then you should can the do_shortcode function to process shortcodes. Do it like this:

<?php $post_id_286 = get_post( 286 ); echo do_shortcode($post_id_286->post_content); ?>

This helped in my case. Hope it will help you too.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736270727a1450.html

最新回复(0)