[一般]->[管理者]のシンジケーション設定の最近の投稿数について、WP管理者の設定を上書きする必要があります。
私はすべての投稿を取得する次のコードを使用していますが、それほど多くは必要ありません。50件の投稿を取得する方法の例を教えてもらえますか?これは、この1つのフィードにのみ影響し、他のすべてには影響しないはずです。
function no_limits_for_feed( $limits ) {
return '';
}
add_filter( 'post_limits', 'no_limits_for_feed' );
更新:これは私が使用しているコードの例です。これはFeedJSONWordPressプラグインからのものです。
class feed_json {
function feed_json() {
global $wp_rewrite;
add_action('init', array(&$this, 'add_feed_json'));
add_action('do_feed_json', array(&$this, 'do_feed_json'), 10, 1);
add_filter('template_include', array(&$this, 'template_json'));
add_filter('query_vars', array(&$this, 'add_query_vars'));
$plugin_basename = plugin_basename(__FILE__);
add_action('activate_' . $plugin_basename, array(&$this, 'add_feed_json_once'));
add_action('deactivate_' . $plugin_basename, array(&$this, 'remove_feed_json'));
}
function add_feed_json_once() {
global $wp_rewrite;
$this->add_feed_json();
$wp_rewrite->flush_rules();
}
function remove_feed_json() {
global $wp_rewrite;
$feeds = array();
foreach ( $wp_rewrite->feeds as $feed ) {
if ( $feed !== 'json' ) {
$feeds[] = $feed;
}
}
$wp_rewrite->feeds = $feeds;
$wp_rewrite->flush_rules();
}
function add_query_vars($qvars) {
$qvars[] = 'callback';
$qvars[] = 'limit';
return $qvars;
}
function add_feed_json() {
add_feed('json', array(&$this, 'do_feed_json'));
}
function do_feed_json() {
load_template($this->template_json(dirname(__FILE__) . '/feed-json-template.php'));
}
function template_json( $template ) {
$template_file = false;
if (get_query_var('feed') === 'json') {
$template_file = '/feed-json.php';
if (function_exists('get_stylesheet_directory') && file_exists(get_stylesheet_directory() . $template_file)) {
$template_file = get_stylesheet_directory() . $template_file;
} elseif (function_exists('get_template_directory') && file_exists(get_template_directory() . $template_file)) {
$template_file = get_template_directory() . $template_file;
} elseif (file_exists(dirname(__FILE__) . '/feed-json-template.php')) {
$template_file = dirname(__FILE__) . '/feed-json-template.php';
} else {
$template_file = false;
}
}
return (
$template_file !== false
? $template_file
: $template
);
}
}
new feed_json();