I'm changing Custom Content Shordcode

Hi there

I am a long-term user Custom Content Shortcode on my sites, I got a message about retirement and I’m going to change it to Loop&Logic

please explain to me that now I have to use TEMPLATE first to use any code?

Before that, I had a lot of content imported with a simple shortcode, eg. [content type=page id=3153]
(Most of my plugin’s use is this)

Now I have to

  1. create a TEMPLATE first

  2. In Template, put the code between <>
    eg.

<Loop type=page id=2>
<Field content />
</Loop>
  1. Then put the shortcode in the wordpress content between [ ]
    eg.
    [template id=4214]

There is no easier method?
I can’t use the code like I used to, but immediately in the shortcode without the template?

Regards, Jakub

I am sorry I did not find an appropriate answer among the topics on forum.

Hi Jakub :slight_smile:

You’re right that you can’t just get the content inline the way you used to, but there’s a simpler solution than your approach:

  1. Create your template
  2. Put this in the template:
<Loop type=page id="{Get local=post_in}">
  <Field content />
</Loop>
  1. Wherever you need to call in the content, use the shortcode this way:
[template id=4214 post_in=3153]

If you prefer, you can also call the template shortcode using the template slug for better readability:

[template name=content post_in=3153]

You can pass any data to your template as a shortcode parameter! When you use the variable in your template, it’s called a Local variable.

Documentation on local variables - Documentation on the Template tag/shortcode

1 Like

Yej!
Thank you - its working and its very smart ! :slight_smile:

1 Like