Issue with shortcode in Raw Content element vs. Text element

Hi!

I’m currently working with a client and building out a site and am creating some shortcodes to pull ad display content from the Learnpress LMS plugin.

My test shortcode is:

function hello_world_function() { return learn_press_get_template( 'single-course/meta/duration.php' ); } add_shortcode('hello_world', 'hello_world_function');

This particular example will pull a particular piece of content from one of their page templates using [hello_world].

The shortcode works great when placed into a Text element. However, when attempting to use a Raw Content element, the content displays outside of its container and at the beginning of the page.

An example can be found here:

You’ll see that “10 Weeks” is what is getting returned from the shortcode, but when placed inside a Raw Element it - for whatever reason - renders at the top of page, well outside of its container. However, when placed inside of a Text element, it appears inline as intended.

Any ideas on this?

A couple of other notes I forgot to mention:

  • It seems to display within a Raw Element in the proper place within the page/layout builder
  • The main goal of this is to be able to easily create a single-course page layout for Learnpress within the Themeco page/layout builder

Hi Tyler,

Thank you for reaching out to us. This could happen if the content returned from the shortcode has errors which will break the layout on the front-end. I tested a different shortcode in the Raw Content element and it works fine. As a test you may try any other shortcode and see if this works for you?

If you still face the issue then please check for the following first:

  1. TESTING FOR PLUGIN CONFLICT
  2. THEME UPDATE
  3. CHILD THEME
  4. CSS/JS CUSTOMIZATION
  5. DISABLING CACHE
  6. VERSION COMPATIBILITY

Let us know how this goes!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.