Get all posts containing a shortcode

WordPress isn’t aware of your shortcode until it’s rendered on the front end. So when WP sees it in the content and replaces it, that’s when it’s aware that your shortcode exists. It also promptly forgets about it afterward, of course. So there’s no built in function to do what you’re asking. The best you … Read more

Make shortcode work with nested double quotes

Either way this seems like a very clunky solution for arbitrary markup in shortcode. If only one of attributes is more bulky and includes markup I would consider making shortcode enclosing: [infobox src=”http://www.google.com” title=”Google”] Some description – see more: <a href=”http://www.google.com”>More here</a> [/infobox] You might be to the point when you’ll need to built custom … Read more

How to add ‘class’ attribute into shortcode [audio]?

WordPress allows least three options to manipulate the code to your needs. Use a global variable that you increment with @Jevuska ‘s answer. global $my_audio_player_count; $my_audio_player_count = 0; add_filter( ‘wp_audio_shortcode_class’, ‘wpse221201_audio_shortcode_class’, 1, 1 ); function wpse221201_audio_shortcode_class( $class ) { global $my_audio_player_count; $class .= ‘ my-audio-player-‘.$my_audio_player_count++; return $class; } Remove the built-in shortcode and add your … Read more

shortcode outputs first before the page content [duplicate]

I guess you’ve echoed the result of shortcode callback function rather than returning them. Please check here: http://codex.wordpress.org/Shortcode_API Shortcodes are written by providing a handler function. Shortcode handlers are broadly similar to WordPress filters: they accept parameters (attributes) and return a result (the shortcode output). you need to return the output that will be added … Read more

using html as shortcode attribute

Pass just the element names and convert them to tags in your shortcode: [irt_top_posts post_type=”showcase” container=”div” number=”10″] In your callback: $return “<$container>$return</$container>”;

Short code to display a loop

There is a multitude issues wrong with the above. For one, post_parent in the query arguments needs to be an integer. You’re assigning it a string. A number of your calls to wordpress functions, such as the_excerpt() and wp_reset_query() are missing ending semicolons. $atts is an associative array of attributes for the shortcode. If you … Read more

Implement If-ElseIf-Else-EndIf with short codes

Having a look at your SO post, seeing the CF Tag output, then seeing what you’re trying to attempt here with shortcodes is, as Otto said, going to be an incoherent mess. There already exists plugins that allow you to write PHP logic amongst your post content, and the following Allow PHP in Posts and … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)