Skip Navigation

[Resolved] ShortCode does not display where it should

This thread is resolved. Here is a description of the problem and solution.

Problem:
My Custom ShortCode does not display where it should. Instead it displays on the Page's Top.

Solution:
It is because your ShortCode is coded badly.
Instead of echoing or printing the SHortCode yumust return it.

Relevant Documentation:
https://codex.wordpress.org/Shortcode_API

This support ticket is created 7 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 8 replies, has 2 voices.

Last updated by DEL 7 years, 10 months ago.

Assisted by: Beda.

Author
Posts
#408404

DEL
screen.png

I'm trying to add custom shortcode to Views Content Template, but have issue with display it properly.

Shortcode need to display at right column after categories list, but it displayed before all views layout.

Can you help me?

#408637

Most probably your ShortCode does echo instead of return the values.

This is a Custom ShortCode that we can not debug for you.

If the ShortCode is coded correctly it will display exactly where you want it to display, as long you do not pass HTML/CSS (positioning) in the ShortCode code itself, and as long it returns the values.

More info here:
https://codex.wordpress.org/Shortcode_API

#408762

DEL

Hi Beda!

I'm trying with echo, print and printf

#408766

DEL

I'm trying to insert shortcode to template file of wordpress theme, where it is displayed correctly. When i trying insert it in Views, receive not properly result.

Maybe need to use alternative method to display values from shortcodes?

In my project Toolset Views used for the majority of the content and archives for custom content types.

#408799

I mentioned, that you can not echo a ShortCode.
You must return it.

Please study the WordPress Codex DOC I passed to you:
https://codex.wordpress.org/Shortcode_API
(especially section "Output")

This has nothing to do with Toolset. Toolset will display your ShortCode exactly where you plant it, as long you correctly code and return this.

If you need help with custom programming, work which is beyond the scope of our support.

At this point I would suggest you consider contacting one of our certified partners from this link:
https://toolset.com/consultant/

You will get the custom assistance you need to get on with your project.

#408804

DEL

I'm change shortcode function with return variable and now it works well!

Thx!

#408895

DEL

remove my code from this topic please

#408898

You should be able to edit your own replies.

It is not really good to remove topic-crucial examples from a thread as the issue will become unclear.

Anyway I have removed all your replies code.

#408902

DEL

thx

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.