Last active
September 1, 2017 07:41
-
-
Save khromov/b5dd8524950ed50ed3a7 to your computer and use it in GitHub Desktop.
WordPress Instant Articles - Prerender pages by meta value - https://wordpress.org/plugins/instant-articles/
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 | |
add_filter('wpinstant_prerendered_urls', function($urls) { | |
if ( is_home() ) { | |
$args = array( | |
'meta_key'=> 'prefetch_on_home', | |
'meta_value' => true | |
); | |
$query = new WP_Query( $args ); | |
if ( $query->have_posts() ) { | |
foreach( $query->posts as $post ) { | |
$permalink = get_permalink( $post->ID ); | |
if($permalink) { | |
$urls[] = $permalink; | |
} | |
} | |
} | |
} | |
return $urls; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment