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

How do grab the main loop, with conditions, and output via shortcodes

Are you sure you want to do this in this manner? Normally a section like this might be written to the page template somehow and not called via the content editor. That being said, this should do what you need: add_shortcode( ‘show_xyz_news’, ‘xyz_news_query’ ); function xyz_news_query() { $args = array( ‘posts_per_page’ => 3, ‘category_name’ => … Read more

How can you alter the name of attributes in a shortcode?

function jk_WPSCEX_add_message( $atts ) { $output=”<a href=”” . $atts[‘link’] . ‘”>’ . $atts[‘text’] . ‘</a>’; return $output; } using the above function shortcode is generated in the form of [jk link=”http://jaskokoyn.com” text=”Like me on Facebook”] OR For Enclosed type of shortcode: function jk_WPSCEX_add_message( $atts, $content = null ) { $output=”<a href=”” . $atts[‘link’] . ‘”>’ … Read more

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