do_shortcode inside AJAX callback

The How It would be much better and easier if you’d just add the script directly to the main body instead of the AJAX call. The same goes with the shortcode result. Just use the shortcode as argument inside wp_localize_script(): wp_localize_script( ‘script-handle’, ‘pluginObject’, array( ‘contactForm’ => do_shortcode( ‘[contact-form-7 id=”698″ title=”Meet The Team Email”]’ ), ) … Read more

how do you get the author’s username?

In the Loop, it would be: $authorname = get_the_author_meta(‘user_nicename’); Or: $authorname = get_the_author_meta(‘displayname’); Or: $authorname = get_the_author_meta(‘nickname’); Or any field that get_the_author_meta() accepts. $authorname = get_the_author_meta(‘user_nicename’,123); If you just need to echo the name just use the_author_meta() instead: the_author_meta(‘user_nicename’,123);

How can I just get content inside a shortcode or just outside

Depends on the shortcode. If you have access to the shortcode’s handler function, that function’s second argument is the content inside the shortcode: function wpse20136_shortcode( $atts, $content ){ // $content has the content inside xxx } register_shortcode( ‘xxx’, ‘wpse20136_shortcode’ ); For getting all content not in shortcodes, that’s easy. strip_shortcodes() does that: strip_shortcodes( get_the_content() ); … Read more

Using action hooks inside of a shortcode

Try this: function example_shortcode( $atts ) { $shortcode_output = “<p>Some shortcode content.</p>”; $shortcode_output .= “<p>More shortcode content.</p>”; ob_start(); do_action(‘below_shortcode’); $below_shortcode = ob_get_contents(); ob_end_clean(); $shortcode_output .= $below_shortcode return $shortcode_output; }

Set wmode attribute to transparent for the embed shortcode to make drop-down menu hover over YouTube embed in Internet Explorer

You can filter the HTML output for oEmbed with oembed_result. Now test the HTTP host of the URL for www.youtube.com and add the parameter. The oEmbed result is cached in a post meta field to avoid too many requests. To update old posts I have added an activation helper that clears those cached content for … Read more

Shortcode attribute value with dash (hyphen)

It’s safe, you won’t have any problem using it, the only caution about Hyphens and Shortcodes comes from the Codex. Take caution when using hyphens in the name of your shortcodes. In the following instance WordPress may see the second opening shortcode as equivalent to the first (basically WordPress sees the first part before the … Read more

Get post id shortcode

Place the below code to your themes functions.php or inside your plugin and the [return_post_id] shortcode will print the post ID. add_shortcode( ‘return_post_id’, ‘the_dramatist_return_post_id’ ); function the_dramatist_return_post_id() { return get_the_ID(); } Hope that helps.

Extract attribute values from every shortcode in post

Method #1 If available, I would use the: shortcode_atts_{$shortcode} filter to collect the attributes of a given shortcode. Example: $text=” “; $out = wpse172275_get_all_attributes( ‘gallery’, $text ); print_r( $out ); with the output: Array ( [0] => [1] => Array ( [ids] => 1,2 https://wordpress.stackexchange.com/questions/172275/extract-attribute-values-from-every-shortcode-in-post => file ) [2] => Array ( [ids] => 3 … Read more

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