How to use webpack in WordPress theme? I want some scripts to load in the footer, some in the header and some with script parameters

What is the right and clean way to load these files in WordPress? The same way as you’ve always done it, wp_enqueue_script. WordPress is unaware that webpack created the javascript file, and it is just that, a javascript file. This is true wether it contains jquery, was written by hand, or was created by a … Read more

Function attached to cron job not running but will run if called manually

It looks like the time() was not set correctly in the first iteration of the function wp_schedule_event; First, remove this task from the queue by adding a function wp_clear_scheduled_hook and reload the page. For your example: wp_clear_scheduled_hook( ‘opportunities_cron_job’ ); Remove the cleaning function. Restart your code. If your date is not set correctly again, use … Read more

BuddyPress Edit activity function good practice

Looking at https://buddypress.trac.wordpress.org/browser/trunk/src/bp-activity/bp-activity-functions.php there’s several functions: Activity Meta I found bp_activity_add_meta, bp_activity_delete_meta and bp_activity_update_meta in that file, e.g. bp_activity_update_meta: // Update activity meta counts. if ( bp_activity_update_meta( $activity_id, ‘favorite_count’, $fav_count ) ) { Activities It looks like these can be updated the same way wp_insert_post can be used to update a post, by calling bp_activity_add … Read more

Proper way to load styles using a child theme

If you want to prevent HELLO from loading it’s own styles, this is the code to paste and adjust in your child theme’s functions.php : function hello_elementor_scripts_styles() { // Dequeue parent theme stylesheets wp_dequeue_style( ‘hello-elementor’ ); wp_deregister_style( ‘hello-elementor’ ); wp_dequeue_style( ‘hello-elementor-theme-style’ ); wp_deregister_style( ‘hello-elementor-theme-style’ ); wp_dequeue_style( ‘hello-elementor-header-footer’ ); wp_deregister_style( ‘hello-elementor-header-footer’ ); // Enqueue only child … Read more

ENV for WordPress

As I don’t know why rails prefer to store such secrets in an environment variable the answer might not be complete, but if the reason is to avoid having it in the code and therefor accessible to everybody with access to the code (via git or misconfigured web server), wordpress has two ways to do … Read more