is_mobile as shortcode

You’ve got an extra “;” after if ( !is_mobile( ) ); Your code should look like this: add_shortcode( ‘is_mobile’, ‘is_mobile_shortcode’ ); function is_mobile_shortcode( $atts, $content = null) { if ( !is_mobile( ) ) return $content; return ”; } And you’ll use it in this way (just for to be sure you’re using it right: [is_mobile]My … Read more

shortcodes inside shortcode to sum values

You can try this: add_shortcode(‘sumsc’,’sumsc_func’); function sumsc_func( $atts, $content = null ) { $sum=0; preg_match_all(‘/stat([0-9]+)/i’, $content, $matches); if(isset($matches[1])){ $sum = array_sum($matches[1]); } return do_shortcode($content).” <div>The sum is <strong>”.$sum.”</strong></div>”; } This will add the total sum at the end of the shortcode content. Usage example: You can try this in your editor: [sumsc][stat1 val=”usa”] [stat2 val=”europe”] … Read more

do_shortcode & render custom field won’t work

Are you sure that you are supposed to nest the shortcodes like this? If the following is going to work depends on how the plugin you use handles nested shortcodes. <?php echo do_shortcode(‘[xt_tabs_button] [xt_tab title=”Informatie”] (types_render_field(“informatie”, array(“output”=>”html”))); [/xt_tab] [xt_tab title=”Spelregels”] (types_render_field(“spelregels”, array(“output”=>”html”))); [/xt_tab] [/xt_tabs_button]’); ?> Do you have the docs for this plugin available? The … Read more

short code output too early

A shortcode has to return just a string, you should not print something like in wp_list_pages() or echo. From Shortcode API: The return value of a shortcode handler function is inserted into the post content output in place of the shortcode macro. Remember to use return and not echo – anything that is echoed will … Read more

Shortcode with multiple variables

If you were to enable debugging and test the code (not sure why you are reluctant to do that), you would see that there are problems with the code. Your array elements need to be separated by commas and PHP variables begin with $. What you have won’t work as is. That kind of pure … Read more

short code output too early

A shortcode has to return just a string, you should not print something like in wp_list_pages() or echo. From Shortcode API: The return value of a shortcode handler function is inserted into the post content output in place of the shortcode macro. Remember to use return and not echo – anything that is echoed will … Read more

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