Last active
November 16, 2017 11:16
-
-
Save evemilano/223b7b948f91e05f68743991e16bfb44 to your computer and use it in GitHub Desktop.
WordPress Dynamic Prerender
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 | |
/* | |
Plugin Name: EVE Dynamic Prerender | |
Plugin URI: https://www.evemilano.com/ | |
Version: 1.0 | |
Description: Inject Dynamic Prerender | |
Author: Giovanni Sacheli | |
Author URI: https://www.evemilano.com/ | |
*/ | |
/*creazione funzione*/ | |
function eve_prerender() { | |
/*echo commento*/ | |
echo '<!-- Prerender dinamico -->'; | |
/*CONDIZIONE 1: se homepage allora*/ | |
if (is_home() ) { | |
echo '<link rel="prerender" href="https://www.evemilano.com/pagina1/">'; | |
} | |
/*CONDIZIONE 2: se post 6999 allora*/ | |
elseif ( is_page(6999) ) { | |
echo '<link rel="prerender" href="https://www.evemilano.com/pagina2/">'; | |
} | |
/*CONDIZIONE 3: se post 13407 oppure 14952 allora*/ | |
elseif ( is_page(13407) or is_page(14952) ) { | |
echo '<link rel="prerender" href="https://www.evemilano.com/pagina3/">'; | |
} | |
/*CONDIZIONE 4: se nessuno dei precedenti allora*/ | |
else { | |
echo '<link rel="prerender" href="https://www.evemilano.com/">'; | |
} | |
} | |
/*inserisci nel codice HTML*/ | |
add_action('wp_head', 'eve_prerender' ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Leggi la guida: https://www.evemilano.com/2017/02/prerender-dinamico-wordpress/