Aşağıdaki sidebar bileşenine ait koda kategori filtresi ekleyerek Kategori ID'si üzerinden bir kategoriyi hariç tutmak istiyorum. Nasıl yapabilirim?
/*
* Created by Pixel-Mafia
*www.pixel-mafia.com
*/
class aurel_featured_posts extends WP_Widget
{
public function __construct()
{
parent::__construct(
'aurel_featured_posts',
'Featured Posts (PM)',
array('description' => '')
);
}
public function update($new_instance, $old_instance)
{
$instance = $old_instance;
$instance['title'] = esc_attr($new_instance['title']);
$instance['number_of_posts'] = absint($new_instance['number_of_posts']);
$instance['featured_images'] = esc_attr($new_instance['featured_images']);
$instance['post_meta'] = esc_attr($new_instance['post_meta']);
$instance['orderby'] = esc_attr($new_instance['orderby']);
return $instance;
}
public function form($instance)
{
$default_values = array(
'title' => esc_html__('Featured Posts', 'aurel'),
'number_of_posts' => '2',
'featured_images' => 'enabled',
'post_meta' => 'enabled',
'orderby' => 'date'
);
$instance = wp_parse_args((array)$instance, $default_values);
?>
}
public function widget($args, $instance)
{
extract($args);
echo $before_widget;
if ($instance['title']) {
echo $before_title;
echo apply_filters('widget_title', $instance['title']);
echo $after_title;
}
$args = array(
'post_type' => 'post',
'orderby' => esc_attr($instance['orderby']),
'post_status' => 'publish',
'posts_per_page' => absint($instance['number_of_posts']),
);
query_posts($args);
if (have_posts()) {
echo '';
while (have_posts()) {
the_post();
echo '
';
}
wp_reset_query();
echo '';
}
echo $after_widget;
}
}
add_action('widgets_init', 'aurel_featured_posts_init');
function aurel_featured_posts_init() {
register_widget('aurel_featured_posts');
}