Skip to content

Instantly share code, notes, and snippets.

@vivek-kumar-poddar
Created August 25, 2017 16:11
Show Gist options
  • Save vivek-kumar-poddar/d33124db5573cb9de52856685ba9a1d5 to your computer and use it in GitHub Desktop.
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.
<?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-&gt;ID ).'" />
<link rel="prerender" href="'.get_permalink( $nxt-&gt;ID ).'" />';
}
if ( !empty( $prv ) ) {
echo '<link rel="prefetch" href="'.get_permalink( $prv-&gt;ID ).'" />
<link rel="prerender" href="'.get_permalink( $prv-&gt;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