Shortcode returns escaped HTML tags

I would recommend using single quotes if you want to include some HTML, also you need to return something otherwise nothing happens. // WP Shortcode function text_shortcode() { return ‘<strong>bold text:</strong> <a href=”https://wordpress.stackexchange.com/questions/318934/shortcode-returns-escaped-html-tags”>See wordpress.stackexchange.com</a>’; } add_shortcode(‘bold-text’, ‘text_shortcode’); Your WordPress shortcode would be: [bold-text] Edit: You don’t need html_entity_decode or htmlentities only when you’re doing something … Read more

Getting attribute value from shortcode

I read your question differently than @eric-holmes. It sounds to me like your shortcode needs to function normally under most circumstances but that you are extracting information in special circumstances. Shortcode regex is tricky. Let WordPress do it for you. $pattern = get_shortcode_regex(); preg_match_all(“/$pattern/”,$wp_content,$matches); Your attributes for any shortcodes present in $wp_content should now be … Read more

Ajax, filters and shortcodes

When WordPress displays post content, it’s not running do_shortcode() on the post content, it’s running apply_filters( ‘the_content’, $content ). Shortcode filters are applied on the_content filter, which is why you have to add extra filters to get them to work in widgets or the footer or elsewhere.

Shortcode not working inside html input

As above, https://wordpress.stackexchange.com/a/195673/22728 solved it: add_filter( ‘wp_kses_allowed_html’, function ( $allowedposttags, $context ) { if ( $context == ‘post’ ) { $allowedposttags[‘input’][‘value’] = 1; } return $allowedposttags; }, 10, 2 );

Localize variable for multiple Shortcodes

Your ploblem is that wp_localize_script print to the html markup a javascript object similar to: var slider = {“id”:”a_unique_id_here”}; if you call it more times, e.g. using more shortcodes in same page, whati is printend in html markup is var slider = {“id”:”a_unique_id_here”}; var slider = {“id”:”another_unique_id_here”}; var slider = {“id”:”third_unique_id_here”}; so you are overwriting … Read more

How to create a shortcode to display a category description?

Try this. Add the code below to your functions.php file – add_shortcode(‘cat_description’, ‘my_cat_description_shortcode’); function my_cat_description_shortcode($atts){ $a = shortcode_atts( array( ‘id’ => 0, ), $atts ); return category_description($a[‘id’]); } Should you wish to call the shortcode from a template (unnecessary really unless you add more to the shortcode) you can use this code – <?php echo … Read more

Adding shortcode inside Visual Composer raw HTML [closed]

When you look at how do_shortcode() actually works, then it’s this: do_shortcode( $content ) Where $content is defined as the following: (string) Content to search for shortcodes What you are trying to do is to echo what the shortcode does, leading to a false assumption. There is no magic function discovering your shortcode. The shortcode … Read more