Shortcodes

Hi there,

Site: https://fantasy-books.live

I am coming to you today for advice. With X Pro, the use of x theme shortcodes have gradually started to decline. Especially considering the former shortcodes are the classical set up.

That being said, they are still being used, and with that, comes questions.

If I were to use a shortcode that’s internally made up of shortcodes… is that a bad idea?

For example. I made a shortcode called ‘Fatty’. Now,

[Fatty] outputs the text “Fatty” + [image]+ [Button], where button and image are x theme shortcodes.

Now, obviously, I don’t use this. But it’s an example of what I’m referring to.

Using Shortcodes to output other shortcodes

Hi there,

It is not possible to have Shortcode inside the Shortcode, but upon coding your shortcode you can use the X shortcode using the do_shortcode WordPress function.

For example, you can add the code below to functions.php of your Child Theme:

add_shortcode('awesome_landmark','awesome_landmark');

function awesome_landmark ( $atts ) {

	ob_start();
	echo 'Pre Text';
	echo do_shortcode( '[recent_posts count="2"]', $ignore_html = false );
	echo 'Post Text';
	return ob_get_clean();

}

The code above creates a shortcode called awesome_landmark which uses the X Recent Post shortcode. And it adds additional text before and after the original Recent Post shortcode.

The Pro theme supports whatever shortcode is listed in the article below under the Shortcodes section:

Thank you.

Thanks. I was unsure if shortcodes within shortcodes would be considered bad coding practice or something for an important reason.

You’re welcome.

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