Tag Info

Hot answers tagged

5

Shortcode callback should return it's output and not echo it. Something like this should work just fine: function get_loggedin_avatar (){ global $current_user; $result = ''; if ( is_user_logged_in() ) { get_currentuserinfo(); $result = '<a href="/myaccount">'. get_avatar( $current_user->ID, 96, left ). ...


3

Return the HTML instead of the echo function dataservices_category($atts) { // Attributes extract(shortcode_atts(array( 'id' => '' ), $atts)); $html = ""; // Code if (isset($id)) { $categories = get_categories('child_of=' . $id); foreach ($categories as $category) { if ($category->parent != $id) { $html .='<div ...


2

Don't try to parse the shortcodes and then regex the HTML. Use get_shortcode_regex() to parse the raw post content: $content = $content_post->post_content; preg_match_all("/$pattern/",$content,$matches); Then crawl $matches to find your shortcode data. Use shortcode_parse_atts($matches[3][0]) (note $matches[3][0] to give the first element within the ...


2

do_action does not return text, it just does the action. So, calling do_action( 'tribe_events_single_event_after_the_meta' ) in your do_shortcode call there will cause the iframe to be output before the shortcode.


2

The main problem here is WordPress COM and ORG are NOT equal. Questions about support for the former are actually off-topic on WordPress Development. One consequence of the non-equality of com and org is that the latter has no shortcode [instagram], so naturally it won't work - the built-in shortcodes can be seen at this list. On the other hand, you are ...


1

you can override the shortcode like this : add_action("init", function () { remove_shortcode("timelinr"); add_shortcode("timelinr", function ($atts, $content) { // call the shortcode of jqueryTimelinrLoad $result = $GLOBALS["jqueryTimelinrLoad"]->shortcode($atts, $content); // dequeue style ...


1

From the codex: The shortcode parser uses a single pass on the post content. This means that if the $content parameter of a shortcode handler contains another shortcode, it won't be parsed. http://codex.wordpress.org/Shortcode_API The codex also provides the solution to your issue, which is to use the funciton do_shortcode() If the enclosing ...


1

Since WordPress 3.6+ There is a function to print out all the media in the content. get_media_embedded_in_content();


1

Use this instead: Concatenate the html then return it. function check_my_login( $atts) { $html = '<form action="" name="" method="post" enctype="multipart/form-data">'; $html .= '<div class="form-group">'; $html .= '<label for="description">Project Description</label>'; $html .= '<textarea name="p_description" ...


1

Thank you for your help I have do some googling and finally i got the ans i have added just 1 line of code into the shortcode function and i got the ans. I have added bellow line into the shortcode function . wp_enqueue_script( 'parent-stylesheet', '[js URL]' . $postId, false );


1

I haven't tested this but based on memory, you are misunderstanding how shortcodes work. The "content" isn't passed through the callback the way you seem to expect it to be. The content is extracted from the post body via a preg_* function. That, if my memory serves, is going to give you "content" as a string no matter what you try to pass into it. As ...


1

Normally Wordpress does not run shortcode that you put into a custom field. By default, Custom Fields display whatever value you enter, as plain-text, so if you try entering a shortcode, (in the format [shortcode] VALUE [/shortcode]) you’ll end up displaying the entire text, including the tags. Add the following in your template file, it can be single.php ...



Only top voted, non community-wiki answers of a minimum length are eligible