Shortcode in loop always display data of first post on the page
Shortcode in loop always display data of first post on the page
Shortcode in loop always display data of first post on the page
The issue you’re encountering is related to the execution order in WordPress. Global variables in WordPress are request-specific and are not preserved across different requests or different parts of a request unless they are included within the same scope. The wp_enqueue_scripts action runs before the template file is executed, hence your $product_filter_data array is still … Read more
Your code has the correct syntax, but for globals to work they have to be run in the same PHP execution (i.e. the same page load), and you’ll need to set that global before you read it. Globals are completely separate to each page load. You either have a case where the code in the … Read more
Global variable not showing in shortcode
Is there a way to natively return the full filesystem path when using $wp_styles? No because the style engine is never given the filesystem path, it is only given the source URL of the style to be registered/enqueued via wp_enqueue_style: wp_enqueue_style( string $handle, string $src=””, string[] $deps = array(), string|bool|null $ver = false, string $media=”all” … Read more
I feel there is a bit of confusion — let me try and clarify some key concepts. A WordPress installation can potentially run huge amounts of 3rd party code. Code you can’t control. That leads to a high chance of naming collisions. That’s why WordPress coding standards suggest to “namespace” functions and variables declared in … Read more
Using global variables
Thanks to @t31os I achieved dequeuing the stylesheet with this code: function disable_classic_theme_styles() { wp_deregister_style(‘classic-theme-styles’); wp_dequeue_style(‘classic-theme-styles’); } add_filter(‘wp_enqueue_scripts’, ‘disable_classic_theme_styles’, 100);
According to comments above, there is no “global” equivalent for functions. So I’m just gonna live with the warning, since everything works.
EDIT: Instead of all that, you could just use a meta_query and “NOT IN” to exclude the feature stories from your second query. That’s the easiest answer. Check out this meta query documentation for help. 1, you need to have do_not_duplicate be a global array in order access it across functions (pretty sure). 2, you … Read more