Last active
December 20, 2015 09:58
-
-
Save roine/6111535 to your computer and use it in GitHub Desktop.
prerender and prefetch in wp
This file contains hidden or 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 if(is_front_page()): ?> | |
| // do not use prefecth on homepage | |
| <?php elseif (is_singular()): ?> | |
| // load the next post, view http://ideasandpixels.com/get-only-url-of-next-and-previous-posts-wordpress | |
| <link rel="prefetch" href="<?php echo get_permalink(get_adjacent_post(false,'',true)); ?>"> | |
| <link rel="prerender" href="<?php echo get_permalink(get_adjacent_post(false,'',true)); ?>"> | |
| <?php else: ?> | |
| <link rel="prefetch" href="<?php echo home_url(); ?>"> | |
| <link rel="prerender" href="<?php echo home_url(); ?>"> | |
| <?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment