カスタム投稿ページのウィジェットからの除外に付いて
-
お世話になっております。
先日、解決していた「最近の投稿」ウィジェットで表示させたくない投稿(タグ)の処理に付きまして、お力をお貸し願えればと思い再度お願いする次第です。
どの様な状態かと申しますと、ワードプレスのバージョン3.1でカスタム投稿タイプに付与しております「info」タグのものを、ウィジェットから除外するコードをfunctions.phpに組み込み問題なく動作していたのですが、「postie」というプラグインがバージョンに対応していないらしく、それに対応させる為に3.05にダウングレードしました。
ところが、バージョン3.05にしたらfunctions.phpに組み込み問題なく動作していたものが、無視されている様な状況になり、大変困っております。
コードは、以下の通り↓
/*最近の投稿*/ add_action( 'widgets_init', 'my_widgets_init' ); function my_widgets_init() { register_widget('my_widget_recent_posts'); } class My_Widget_Recent_Posts extends WP_Widget_Recent_Posts { function My_Widget_Recent_Posts() { $widget_ops = array('classname' => 'my_widget_recent_entries', 'description' => 'info以外の最新の投稿' ); $this->WP_Widget('my-recent-posts', __('Recent Posts'), $widget_ops); $this->alt_option_name = 'widget_recent_entries'; add_action( 'save_post', array(&$this, 'flush_widget_cache') ); add_action( 'deleted_post', array(&$this, 'flush_widget_cache') ); add_action( 'switch_theme', array(&$this, 'flush_widget_cache') ); } function widget($args, $instance) { $cache = wp_cache_get('my_widget_recent_posts', 'widget'); if ( !is_array($cache) ) $cache = array(); if ( isset($cache[$args['widget_id']]) ) { echo $cache[$args['widget_id']]; return; } ob_start(); extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts') : $instance['title'], $instance, $this->id_base); if ( ! $number = absint( $instance['number'] ) ) $number = 10; $id = get_term_by( 'slug', 'info', 'post_tag' )->term_id; $r = new WP_Query(array('tag__not_in' => $id, 'posts_per_page' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'ignore_sticky_posts' => true)); if ($r->have_posts()) : ?> <?php echo $before_widget; ?> <?php if ( $title ) echo $before_title . $title . $after_title; ?> <ul> <?php while ($r->have_posts()) : $r->the_post(); ?> <li><a href="<?php the_permalink() ?>" title="<?php echo esc_attr(get_the_title() ? get_the_title() : get_the_ID()); ?>"> <?php if ( get_the_title() ) the_title(); else the_ID(); ?> </a></li> <?php endwhile; ?> </ul> <?php echo $after_widget; ?> <?php wp_reset_postdata(); endif; $cache[$args['widget_id']] = ob_get_flush(); wp_cache_set('my_widget_recent_posts', $cache, 'widget'); } } ?>
ダウングレードに問題があったのか、、上記コードで引っ掛かっているのか皆目見当が付きません。
どちら様か、良きアドバイスを頂けましたら幸いです。
6件の返信を表示中 - 1 - 6件目 (全6件中)
6件の返信を表示中 - 1 - 6件目 (全6件中)
- トピック「カスタム投稿ページのウィジェットからの除外に付いて」には新たに返信することはできません。