Dans un souci d’alléger mon blog, je me suis mis à la chasse des plugins WordPress inutiles.
Première cible : « Similar Posts », un plugin qui permet d’afficher les articles similaires à celui consulté.
Voici donc le code à placer ou bon vous semble dans votre fichier single.php et qui remplacera avantageusement un plugin :
[php]
<?php
$original_post = $post;
$tags = wp_get_post_tags( $post->ID );
if( $tags )
{
echo ‘<h3>Articles Similaires</h3>’;
$first_tag = $tags[0]->term_id;
$args=array(
‘tag__in’ => array( $first_tag ),
‘post__not_in’ => array($post->ID),
‘showposts’=>4,
‘caller_get_posts’=>1
);
$my_query = new WP_Query($args);
if( $my_query->have_posts() )
{
echo "<ul>";
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
<?php endwhile;
echo "</ul>";
}
}
$post = $original_post;
wp_reset_query();
?>
[/php]
Derniers commentaires