Created
May 18, 2017 14:30
-
-
Save diije/eaa75cce2fc17b14113288314892ebb4 to your computer and use it in GitHub Desktop.
WordPress : Afficher le widget des articles récents sur toutes les pages sauf la page d'accueil.
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 | |
if ( ! function_exists('dfr_recent_articles') ) { | |
function dfr_recent_articles() { | |
if(!(is_home() || is_front_page())) { | |
echo '<section id="dfr_widget" class="widget widget_recent_entries">'; | |
echo '<h2 class="widget-title">Articles Récents</h2>'; | |
echo '<ul>'; | |
$lastposts = get_posts(); | |
foreach ( $lastposts as $post ) : setup_postdata($post); ?> | |
<li><a href="<?php echo get_permalink($post->ID); ?>"><?php echo $post->post_title; ?></a></li> | |
<?php endforeach; | |
echo '</ul>'; | |
echo '</section>'; | |
} | |
} | |
wp_register_sidebar_widget( | |
'dfr_widget', | |
'Mes Articles Récents', | |
'dfr_recent_articles', | |
array( 'description' => 'Affiche les articles récents seulement sur les pages internes.' ) | |
); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment