Archive

Articles taggués ‘wordpress’

Front Page Categories

16/04/2010

Mise à jour d’une petite extension wordpress pour sélectionner les catégories qui doivent être affichées en homepage d’un blog wordpress :

<?php
/*
Plugin Name: Front Page Categories
Version: 0.3
Plugin URI: http://www.damiencuvillier.com/2010/04/16/front-page-categories/
Description: Select categories to display on the front page.
Author: Ryan Boren & Damien Cuvillier*/
function fpc_where($where) {
// Change this to the categories you want to show on the front page.
// Example:  $cats_to_show = ’1 2 3 4′;
$cats_to_show = ’44 4′;
global $wpdb, $wp_query;
if (! $wp_query->is_home) {
return $where;
}
$cat_array = explode(‘ ‘, $cats_to_show);
$where .= « AND  » . $wpdb->posts . « .ID IN (SELECT object_id FROM  » . $wpdb->term_relationships ;
$where .=  » LEFT JOIN  » . $wpdb->term_taxonomy .  » ON  » . $wpdb->term_taxonomy . « .term_taxonomy_id =  » . $wpdb->term_relationships . « .term_taxonomy_id « ;
$where .= « WHERE ( » . $wpdb->term_taxonomy. ».term_id = « ;
$where .= implode(‘ OR ‘.$wpdb->term_taxonomy.’.term_id = ‘, $cat_array);
$where .= « )) »;
return $where;
}
add_filter(‘posts_where’, ‘fpc_where’);
?>

  • Twitter
  • Buzz
  • Facebook
  • LinkedIn
  • Picasa