Shortcode with foreach

You’re trying to concatenate a foreach statement in to a string, which can’t be done… You need to add the output that you need to your existing string, not concatenate it function create_galeri_shortcode( $atts ) { $atts = shortcode_atts( array( ), $atts, ‘galeri’ ); if ( has_post_format( ‘gallery’ ) ) { $images = get_post_meta( get_the_ID(), … Read more

Shortcode content is empty [closed]

It is the hyphen: Take caution when using hyphens in the name of your shortcodes. In the following instance WordPress may see the second opening shortcode as equivalent to the first (basically WordPress sees the first part before the hyphen): Rename your shortcode so the tag doesn’t have a hyphen.

Shortcode leads to white screen [closed]

As I already stated in comments, your code is a complete mess and very hard to read and to debug. This is most probably why you are having a hard time to sort your issues. Apart from a few syntax errors, you had a couple of bugs in your code like undefined variables (like your … Read more

Using $variable in shortcode

If you’re using PHP > 5.3, then you can use a closure on the the_content filter. This filter needs to be added after the $variable has been defined and before the the_content filter has fired. add_filter( ‘the_content’, function( $content ) use ( $variable ) { return str_replace( ‘[variable][/variable]’, $variable, $content ); } ); Shortcodes are … Read more

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]’)

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

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