Inserting PHP inside do_shortcode

This is the code I would use: $open_shortcode=”[vc_accordion]”; $shortcode_data=””; $close_shortcode=”[/vc_accordion]”; $myarray = array( ‘tabs’ => array( ‘title’ => ‘Section 1’, ‘content’ => ‘Any text here’ ), array( ‘title’ => ‘Section 2’, ‘content’ => ‘Any text here’ ) ); foreach( $myarray[‘tabs’] as $tab ){ $shortcode_data .= ‘[vc_accordion_tab title=”‘ . $tab[‘title’] . ‘”]’ . $tab[‘content’] . ‘[/vc_accordion_tab]’; … Read more

Using API to generate short link

You never need do_shortcode(), better said, almost never, there are a few cases where do_shortcode() could be appropiate. Note how you could do just: echo shorten_url( ‘http://mylink.com ‘ ); instead of: echo do_shortcode(‘[shorten]http://mylink.com[/shorten]’); Think about shortcodes as PHP functions placeholders; they are intended to be use where you can not execute PHP directly, like the … Read more

WordPress shortcode doesn’t working on HomePage

Depending on what post editor you are using: Classic – make sure to switch the editor to “Text” instead of “Visual”. The latter will output anything you write in a form of text, while the first one will process the shortcode. Gutenberg – find a plus sign in the top-left area of your WordPress dashboard … Read more

Add page title as a javacript variable to specific posts

Use a shortcode. In your plugin or theme (functions.php) add: add_action( ‘after_setup_theme’, ‘wpse_42534_add_permalink_shortcode’ ); function wpse_42534_add_permalink_shortcode() { add_shortcode( ‘permalink’, ‘get_permalink’ ); } Now, your users can use the string anywhere in the post to print the URI to the current post or page. Oh, and welcome to WordPress Stack Exchange!

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