How to build a shortcode for tabs
I modified the code you shared a little. You can try this: http://pastebin.com/sAshJ348 Change the classes where necessary. Thanks
I modified the code you shared a little. You can try this: http://pastebin.com/sAshJ348 Change the classes where necessary. Thanks
You can use do_shortcode() echo do_shortcode($post_customs[“project_items_”.$i.”_edit_proposal_item”][0]); More : http://codex.wordpress.org/Function_Reference/do_shortcode
What if you concatenate the string, like $author_ig = ‘[instagram-feed id=”‘ . get_the_author_meta(‘instagram’) . ‘” imageres=”full” showheader=”true” showbutton=”true” buttoncolor=”#fff” buttontextcolor=”#000″ showfollow=”false”]’; echo do_shortcode($author_ig); I used get_the_author_meta instead of the_author_meta, because the former returns the meta as a string while the latter echo’s the meta.
I’d expect that the final return do_shortcode($return); is the problem as it tries to process a shortcode named the entire content you are about to return and return a value. I expect that this is not what you are intending there. Try changing that to: return $return; If that does not fix things, then I’d … Read more
I finally make it ready after some more research. function coregnie_list_ul( $atts, $content = null ) { extract(shortcode_atts(array( ‘style’ => ‘cg_list’, ), $atts)); return ‘<ul class=cg_list_’.$style.’ >’.do_shortcode($content).'</ul>’; } add_shortcode(‘ul’, ‘coregnie_list_ul’); function coregnie_list_li( $atts, $content = null ) { return ‘<li>’.do_shortcode($content).'</li>’; } add_shortcode(‘li’, ‘coregnie_list_li’);
In order to get your shortcode to show up, you have to register it first. This is done with add_shortcode(). You can read more about the Shortcode API in the Codex. Here is an example of a Youtube video-shortcode that accepts 3 parameters; Video ID (from Youtube, the last part of the Youtube url), height … Read more
When you set the third parameter of get_post_meta to true, the function returns a string, as you can read in the codex. So: $arr = get_post_meta($post->ID, ‘tab_details’, true); Makes $arr be a string and a string is not a valid argument for a PHP foreach loop and that is waht the error message says. Instead, … Read more
Shortcode’s callback should return a string, not echo it. function getMyShortCode_func() { return ‘<div class=”abc”>Hello world.</div>’; }
There’s no need to replicate The Loop in your plugin; WordPress is working within a post when it processes a shortcode, so the post ID is available when the shortcode is being processed. Also, your arguments for has_term are out of order. And finally, it’s a best practice to make a shortcode all one word. … Read more
This is probably the result of the wordpress 4.0.1 security fix which changed how shortcodes are handled http://wptavern.com/wordpress-4-0-1-exposes-bad-development-practices-used-in-some-plugins. While I am not sure about the details your shortcode handling seems to match the general description of trying to parse the shortcode by yourself instead of properly registering it. To fix this you need to create, … Read more