Need help with PHP functions

add_shortcode(‘show_name’, ‘generate_content’); When WordPress finds a [show_name] shortcode tag in content, it runs the function that matches the second parameter, which in this case is generate_content. Try renaming your show_name() function to be the same, like this: add_shortcode(‘show_name’, ‘my_show_name_func’); function my_show_name_func() { $current_user = wp_get_current_user(); $first_name = $current_user->user_firstname; return $first_name; } Everything else looks like … Read more

Get current category and place it in shortcode

So, you can get the category name with get_queried_object()->name: if ( is_category() ) { echo do_shortcode( ‘[x_recent_posts type=”post” count=”2″ offset=”” category=”‘ . get_queried_object()->name . ‘” orientation=”vertical” no_sticky=”true” no_image=”false” fade=”false”]’ ); }

How to add a shortcode to an HTML image tag

Use a separate function to enable shortcodes in the text widget because trying to do so within the shortcode function itself is too late. // Enable the use of shortcodes within the text widget. function wpse249090_widget_text_enable_shortcodes() { add_filter( ‘widget_text’, ‘do_shortcode’ ); } add_action( ‘init’, ‘wpse249090_widget_text_enable_shortcodes’ ); // Do TimeStamper Shortcode ( timestamper() ) function timestamper( … Read more

Multiple calling javascript from shortcode in one page

A script should be enqueued and localized only one time per page; so, what you describe is the correct behaviour. I think you are confusing localizing a script with printing inline JavaScript. Also, enqueuing and localizing should be done in wp_enqueue_scripts action. You need to think in a different approach. For example (just a example), … Read more

How do i remove Business feeds Shortcode fatal error

This is probably the issue: $currency = wp_remote_get($current_ping); if($currency){ $currency will either be a WP_Error object or an array. Checking if($currency) will be true in both cases. Instead, you should check if it’s an array and not an error object: if ( is_array( $currency ) && ! is_wp_error( $currency ) ) { of course, that … Read more