WordPress – How to add an attribute to a plugin inline script tag

The script <script type=”text/javascript” id=’nf-front-end-js-extra’> is added via the wp_localize_script function, and you can’t add attributes using the script_loader_tag filter. This filter can only be used for scripts added via wp_enqueue_script. In your case, you should use the wp_inline_script_attributes filter. Try using the following code: // NAV: Add attributes to inline script nf-front-end-js-extra function wpcoder_to_script … Read more

When to use WP_query(), query_posts() and pre_get_posts

You are right to say: Never use query_posts anymore pre_get_posts pre_get_posts is a filter, for altering any query. It is most often used to alter only the ‘main query’: add_action(‘pre_get_posts’,’wpse50761_alter_query’); function wpse50761_alter_query($query){ if( $query->is_main_query() ){ //Do something to main query } } (I would also check that is_admin() returns false – though this may be … Read more

Updates applied to staging WordPress site affecting production even with different databases

I have resolved my issues by reviewing the Redis Cache plugin installation guide and making the following changes inside the wp-config.php files on each WordPress installation. The define( ‘WP_REDIS_PREFIX’, ” ); was added with the values set as production, staging, and beta for each respective site. The define( ‘WP_REDIS_DATABASE’, 0 ); values for the staging … Read more

do_blocks not working with a custom block

It could be that the block is processing CSS, and that CSS processing has already occured. You need to thus run the do block in the header, or that is the solution I’ve been told. I’ve not gotten it to work, for myself.