Query by Category and Custom Field – Shortcode
Query by Category and Custom Field – Shortcode
Query by Category and Custom Field – Shortcode
So I spent like 5 hours trying to figure out why my proper-looking code wasn’t giving me the behavior I wanted. Thanks to the fine commentators I was able to get current posts to display without the event_date specified but wasn’t able to fetch posts by date. I started thinking outside of the box and … Read more
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
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”]’ ); }
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
Shortcode in a $output statement
How to make shortcode enabled in JSON Feeds?
I guess that Visual Composer is not running the Rest API space, probably it’s better contact the support of that plugin. In any case you can see if you can execute the method of the visual composer plugin used for the shortcode and run in your code.
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
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