Execute shortcode twice in the same page

I believe the real issue you had was with echoing your data instead of returning it. A shortcode should return the output to be drawn, which is then drawn in place of the short code. Here is the code using HEREDOC syntax for outputs and the query. I believe this makes things much more readable … Read more

Add attribute to shortcode dynamically

Untested (and can’t test right now) but you ought to be able to add attributes with a filter… something like: function test_sc($atts,$content) { // echo ‘test_sc’; $atts = shortcode_atts( array( ‘foo’ => ‘no foo’, ‘bar’ => ‘default bar’, ), $atts, ‘testsc’ ); // var_dump($atts); } add_shortcode(‘testsc’,’test_sc’); function test_shortcode_att_add($atts) { # this filter should only run … Read more

Placing raw HTML inside a WordPress shortcode

For the sake of having @Milo’s comment as an answer. Your code works as it should, it is just not possible to “write” HTML in the visual editor also in shortcodes. Shorcodes are not treated differently then any other text. If you want formatted HTML in your shortcode you just need to use the normal … Read more

Shortcode to generate and save password in a file

Per the comment under the OP’s question, below is the solution by using a return instead of an echo: add_shortcode( ‘phptest’, ‘custom_shortcode_phptest’ ); function custom_shortcode_phptest() { // Add Shortcode function generatePassword( $length = 6 ) { $characters=”0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ”; $charactersLength = strlen( $characters ); $pass=””; for ( $i = 0; $i < $length; $i++ ) { $pass … Read more

Error do_shortcode In WooCommerce Template

I solved this with dirty way.. hope someone else can provide more efficient solution, my final working code for problem above: $shortkode=”[zendesk_request_form size=”3″ group=”extra-field” subject=”Quotation For -wkwkwk-“]”; $shortkode = do_shortcode( $shortkode ); add_action(‘woocommerce_single_product_summary’, ‘quotation_form’, 61); function quotation_form() { $produk = get_the_title(); global $shortkode; $shortkode = str_replace(“-wkwkwk-“, $produk, $shortkode); echo $shortkode; } So i move out … Read more

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