Change default s.w.org dns-prefetch resource hint value

var_export( $hints ); gave me array ( 0 => ‘https://s.w.org/images/core/emoji/2.4/svg/’, ) so that means the array key is not s.w.org but https://s.w.org/images/core/emoji/2.4/svg/. Changing the function and using the key of the array with the full url did remove the s.w.org hint while still letting me use resource hints. function resource_hints( $hints, $relation_type ) { if … Read more

How to get a single hook from wp_head()?

wp_head is an essential part of the theme, and there is too many things that might fall apart if it is not there. Hunting and fixing them one by one might be time consuming and the worthiness of the all operation questionable. In you snippet for example you want to remove things that make no … Read more

Custom script file enqueue has “?ver=4.5.1” when loading and doesn’t update

I agree with @Mark Kaplun – what you’re describing is an odd behavior though. Try this markup to override the $ver param. wp_enqueue_script( ‘script’, get_template_directory_uri() . ‘/js/script.js’, array ( ‘jquery’ ), null, true); https://developer.wordpress.org/themes/basics/including-css-javascript/ Alternatively, to work around the version cache try this markup which will generate a unique version with each page load. wp_enqueue_script( … Read more

ACF custom field in [closed]

In the header.php template, you cannot access the $post variable. So you will have to map it using $wp_query, as mentioned on ACF forum here. Try this: <?php global $wp_query; $post = $wp_query->post; $background = get_field(‘background’, $post->ID); ?> <style> .site-header { background: url(<?php echo $background; ?>) no-repeat center; background-size: cover; } </style>

Inject HTML meta tag inside wordpress tag using add_shortcode

First thing, wp_head action hook does not accept any argument at all, so am not sure whether the $url variable will be passed. To run the short code properly, you have to call do_shortcode(): add_action( ‘wp_head’, ‘refresh_page’ ); function refresh_page() { echo do_shortcode( “[refresh url=”http://stackoverflow.com”]” ); } add_shortcode( ‘refresh’, ‘refresh_shortcode’ ); function refresh_shortcode( $atts ) … Read more