Created
August 25, 2017 16:11
-
-
Save vivek-kumar-poddar/d33124db5573cb9de52856685ba9a1d5 to your computer and use it in GitHub Desktop.
https://wpvkp.com/enable-dns-prefetch-wordpress-instant-articles-plugin -- This code will help you to enable dns prefetch in wordpress.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // ************* DON'T COPY ME *************** | |
/* This is for next and previous post */ | |
function wpvkp_dnsprefetch_next_previous() { | |
$nxt = get_next_post(); | |
$prv = get_previous_post(); | |
if ( !empty( $nxt ) ) { | |
echo '<link rel="prefetch" href="'.get_permalink( $nxt->ID ).'" /> | |
<link rel="prerender" href="'.get_permalink( $nxt->ID ).'" />'; | |
} | |
if ( !empty( $prv ) ) { | |
echo '<link rel="prefetch" href="'.get_permalink( $prv->ID ).'" /> | |
<link rel="prerender" href="'.get_permalink( $prv->ID ).'" />'; | |
} | |
} | |
add_action( 'wp_head', 'wpvkp_dnsprefetch_next_previous', 10 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment