Custom function in My Custom Functions returning 403

You can use wp_head. This will insert the script in the head. function dropin_location() { if ( is_page( 7 ) ) { ?> <script>alert(‘got here’)</script>’ <?php } } add_action(‘wp_head’, ‘dropin_location’); However, there are other ways to add scripts. You can have it as a script file in your theme and enqueue it so that WordPress … Read more

Adding widget to dashboard with wp_dashboard_setup not working

Use this code to require the file from your theme’s functions.php file: require get_template_directory() . ‘includes/dashboard.php’; For the sake of completeness (and sanity) my dashboard.php file lives here: my-theme/includes/dashboard.php I took a closer look at the original issue, and I think what’s happening is that the require statement is silently failing because the wp-admin/includes/dashboard.php file … Read more

Avoid loading css from parent theme

In your child theme (which I am assuming you are using) functions.php file: function wpse_356175_assets() { wp_dequeue_style( ‘media-queries’ ); } add_action( ‘wp_enqueue_scripts’, ‘wpse_356175_assets’ ); Utilise wp_dequeue_style and or wp_deregister_style depending on how the stylesheet was registered/enqueued. If necessary adjust the priority of your action to fire after the registered/enqueued file from the parent theme, e.g: … Read more

Adding to fontawesome-webfont.woff2 to boost website speed

If your theme is any good it will use wp_enqueue_style to include fonts in the head of your site. This gives you access to the style_loader_tag filter, which you can use to modify the html of the font link. Like this: add_filter( ‘style_loader_tag’,’wpse366869_preload_styles’, 10, 4 ); function wpse366869_preload_styles( $html, $handle, $href, $media ) { // … Read more

Display first name of logged in user?

The issue here is that both the functions have the same name – colaborator_avatar(). Make sure that $new_user contains the current user. Else use get_current_user_id() like this: get_user_meta( get_current_user_id(), ‘first_name’, true ); Show avatar and first name: // show user avatar if logged in function colaborator_avatar($atts) { if (is_user_logged_in() && !is_feed()) { return get_avatar(get_the_author_meta( ‘user_email’ … Read more