admin管理员组

文章数量:1289845

For a project I want to use advanced shortcodes. Normally I define shortcodes within my PHP. This way it is always the information I have in my PHP-files that I show with my shortcodes (like [shortcode]). In this project the traffic is different. I need to get information inside in my shortcode that I need to use in a variable in my PHP. This so I can use in my Wordpress editor shortcodes like [shortcode "1"] or [shortcode "2"]. This value from within the "" is a value that I will use to do something in my PHP. This way I don't need to make several shortcodes with countless options but will be way more clean. It will become a kindoff template.

I know it is possible but I don't know how. I have no experience with this kind of traffic and can't find any documentation about this. Hope you guys can help me out with this.

For a project I want to use advanced shortcodes. Normally I define shortcodes within my PHP. This way it is always the information I have in my PHP-files that I show with my shortcodes (like [shortcode]). In this project the traffic is different. I need to get information inside in my shortcode that I need to use in a variable in my PHP. This so I can use in my Wordpress editor shortcodes like [shortcode "1"] or [shortcode "2"]. This value from within the "" is a value that I will use to do something in my PHP. This way I don't need to make several shortcodes with countless options but will be way more clean. It will become a kindoff template.

I know it is possible but I don't know how. I have no experience with this kind of traffic and can't find any documentation about this. Hope you guys can help me out with this.

Share Improve this question edited Jul 30, 2021 at 12:46 Ricardio asked Jul 30, 2021 at 12:18 RicardioRicardio 381 silver badge8 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 0

I think Shortcodes with Parameters is what you’re looking for.

https://developer.wordpress/plugins/shortcodes/shortcodes-with-parameters/

You can find the solution for this case at https://codex.wordpress/Shortcode_API

本文标签: phpGet value from shortcode to do something