Wpautop stops working after get_the_excerpt

wpautop has got to be my least favorite part of working with WordPress. Just when everything else is working, it sticks its fingers into everything… The problem has to do with filter priority, as you noted earlier. In the case of the excerpt, we’re interested in the filter get_the_excerpt. I haven’t been able to figure … Read more

Add the results of a custom query into a do_shortcode

I hope I understand you correctly, so I’m going to answer accordingly. For this to work, you’ll need to add the complete custom query inside a shortcode. Have a look at the Shortcode API how short codes work and how it is used. One thing to remember though, the output from a shortcode should not … Read more

php code to shortcode [duplicate]

Hi You can use this code. function wpse_143641_profile_shortcode( $atts ) { echo get_avatar( get_current_user_id(), 64 ); } add_shortcode( ‘royal_profile’, ‘wpse_143641_profile_shortcode’ ); And you should add the short code in your editor [royal_profile] or template do_shortcode(‘[royal_profile]’)

How to show in front End images using Visual Composer attach_images?

$gallery = shortcode_atts( array( ‘post_gallery’ => ‘post_gallery’, ), $atts ); $image_ids=explode(‘,’,$gallery[‘post_gallery’]); $sigle_img = wp_get_attachment_image_src($image_ids[0], “large”); $img=”<div id=’tourGallery’><img class=”imgthumb” id=” src=””.$sigle_img[0].”” style=”width:100%” alt=””></div><div id=’galleryThumbs’>”; for($i=0;$i<=9;$i++) { if($image_ids[$i]!=””) { $imgs = wp_get_attachment_image_src($image_ids[$i], “large”); $img.=”<div><img class=”imgthumb” id=” src=””.$imgs[0].”” style=”width:100%” alt=””></div>”; } } $img.=”</div></div>”; return $img; Achieved!!!

Insert shortcode in widget area

Shortcodes are not parsed in widget text – you need to tell WordPress to do so: add_filter( ‘widget_text’, ‘do_shortcode’ ); Place it in your theme’s functions.php

Enclosing shortcodes create line breaks

If you want to just strip the <br /> from the content then you could modify your function to replace that signature with an empty string. It feels like a dirty hack, but it’s working for me. It’s worth noting that my Chrome tools show <br> but the actual code is rendering <br /> which … Read more