How to pass an array as attribute of shortcode to work properly shortcode parser?
Try… base64_encode(serialize($array)) base64_encode(json_encoe($array)) and reverse decoding in shortcode ofcourse
Try… base64_encode(serialize($array)) base64_encode(json_encoe($array)) and reverse decoding in shortcode ofcourse
I am also seeking the same solution. I am going to create a gallery filter function – an extension to this. Do you want to collaborate? function get_post_gallery( $post = 0, $html = true ) { $galleries = get_post_galleries( $post, $html ); $gallery = reset( $galleries ); /** * Filter the first-found post gallery. * … Read more
You have to rely on javascript for the redirect. You can set it like this in your shortcode. $html = “<script> location.href = “https://wordpress.stackexchange.com/questions/157922/. $home_url() .” </script>”; return $html; It will load the page and then redirect immediately.
A possible solution, a good one I think, is to use a object with a property to store the validation status so you set the value of this property in the init action hook where you process the form and access to it in the shortcode. For example: class MyForm { private $validate; function __construct() … Read more
You should try this on a default theme (without any plugins), to see if that makes any difference. Your shortcode example: gives this output: <div id=”my-caption-id” style=”width: 409px” class=”wp-caption alignnone my-caption-class”> <img src=”https://wordpress.stackexchange.com/questions/158628/whatever.jpg” alt=”whatever” width=”399″ height=”600″> <p class=”wp-caption-text”>My caption text</p> </div> on the Twenty Twelve theme. It’s just a little bit formatted to make it … Read more
I would rather pass the variable to the id attribute inside the shortcode. You can even decide to remove the id attribute inside the shortcode and make it a static value that you pass to your custom query For examples and more info about how shortcodes operate, check out the Shortcode API
I believe esc_url() is what you’re looking for? here’s shortcode code: add_shortcode(‘urlencode’,’shortcode_urlencode’); function shortcode_urlencode($atts,$content=””) { return esc_url(do_shortcode($content)); } not tested, but should work.
<?php function url_fetcher(){ $pageURL = ‘http’; if ($_SERVER[“HTTPS”] == “on”) {$pageURL .= “s”;} $pageURL .= “://”; if ($_SERVER[“SERVER_PORT”] != “80”) { $pageURL .= $_SERVER[“SERVER_NAME”].”:”.$_SERVER[“SERVER_PORT”].$_SERVER[“REQUEST_URI”]; } else { $pageURL .= $_SERVER[“SERVER_NAME”].$_SERVER[“REQUEST_URI”]; } //echo $pageURL; $str = explode(“https://wordpress.stackexchange.com/” ,$pageURL); //print_r($str); $str1 = $str[3]; echo $str1.'<br \>’; $str2 = explode(“-“, $str1); $cat = $str2[0]; echo $cat.'<br \>’; $dog … Read more
Your sort of right, the WordPress editor saves content thru a filter called the_content. This filter is used to filter the content of the post after it is retrieved from the database and before it is printed to the screen. Apply this filter to simulate TinyMCE formatting. <?php echo apply_filters( ‘the_content’, $options[‘textarea_input’]); ?>
I wanted to elaborate on the answers with examples for those who need help. How to count shortcodes in a post Possible reasons you are here: Multiple instanced of same shortcodes with unique id You need the same shortcode outputting unique class each call Set a variable counter to count shortcode usage How to count … Read more