2

Good to hear that you managed to solve the problem already. Here's a few examples on how you could also return html from a shortcode. As you already found out, you can use ob_start() and ob_get_clean() to buffer the html. Inside it you can echo the markup or drop out of PHP and write plain HTML. function my_shortcode() { ob_start(); echo '<div>...


1

get_next_post returns null if there is no post anymore. And then get_permalink will have a null value for $next_post, so it will get the permalink for the current post, resulting in linking to the same post again and again. You should thus check for null, and if so, link to the first (latest) post. Something along the lines of (in your code style): function ...


1

// hijack the download shortcode add_shortcode( 'dlm_gf_form', array( $this, 'shortcode_dlm_gf_form' ) ); This line just adds a shortcode from a class. I checked this plugin's class and they didn't provide any actions or filter. You can try to modify original code of this plugin for your purposes only. I don't see any other solution. I don't know what this ...


1

I never worked with this plugin, just downloaded it from repository and found that they provide a filter for id value. Add this filter callback function to your functions.php file. [download id="auto"] - will use id from your post meta (hardcoded meta name) [download id="123"] - will use id 123 function download_shortcode_custom_id($id,...


1

Used shorcodes can be retrived only if they are added in post content (or any content saved in db). They can not be retrived if hardcoded in template files (TBH, they can, but that's not the issue here). This code can help you to get the shortcodes used in a post content. function wpse387291_get_shortcodes() { global $post; $pattern = ...


1

You're only registering the shortcode on activation. add_shortcode() is not persistent, and since shortcodes are parsed on output, the shortcode needs to be registered on every request. So you need to move add_shortcode() outside of the activation hook: function install_myplugin() { // ... } function uninstall_myplugin() { // ... } function ...


1

First, I will add here 3 resources for learning most of the things you need about shortcodes: Official WP Docs A good article Another article that I wrote The idea is that you don't echo the content in your shortcode, but you return it so that WordPress can only print it where it is needed. For your specific shortcode, the code should look look like this: ...


1

As Tom J Nowell noted in the comments, your setup is bit wonky, which is why it won't work. You need to add the ajax actions and register the shortcode earlier - i.e in a custom plugin or in the theme functions.php. This is related to how WordPress handles requests and in which order it loads and does things - the action reference on Codex sheds some light ...


1

function parse($stuff, $template) { ob_start(); $output = ''; include $template; $output = ob_get_contents(); ob_end_clean(); $output = do_shortcode($output); // This line will parse shortcodes from $template return $output; } To add some details: your main shortcode, [ta-intentclicks], I assume you're placing that in the Page/...


1

If I understand it correctly, inside the shortcode template, you could do something like this: echo do_shortcode( '[ta-intentclicks-link url="' . esc_url( $list_item['link'] ) . '"]Visit website[/ta-intentclicks-link]' ); But then, instead of having to use do_shortcode(), you could actually simply call the shortcode callback from the (shortcode) ...


1

You can place only the following code in functions.php and it will work: // Activate Shortcode Execution for Contact Form 7 add_filter( 'wpcf7_form_elements', 'do_shortcode' );


Only top voted, non community-wiki answers of a minimum length are eligible