English 中文(简体)
如何凌驾于习俗饲料产品浓缩限值之上?
原标题:How to get override the WP Admin Syndication feed limit for a custom feed?

我必须超越在工作计划中为“合成物”下“合成物”环境中最近员额的设置。

我使用以下法典,即所有员额,但我不需要这么多人。 让我举一个例子,说明如何收回50个员额? 这只能影响这一饲料,而不是所有其他饲料。

function no_limits_for_feed( $limits ) {
    return   ;
}

add_filter(  post_limits ,  no_limits_for_feed  );

<><>UPDATE: The following s a example of the Code I am used, which is from the Feed JSON 说 明 Press plug-in:

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();
最佳回答

我认为,你可以 h到>>,但如果是posts_per_page 价值后来超写。 因此,仅打上<代码>的标语——限值,对您的馈赠进行检查,必要时再回一个不同的<代码>LIMIT部分。

add_filter(  post_limits ,  so6230475_post_limits , 10, 2 );
function so6230475_post_limits( $limits, &$wp_query )
{
    if ( $wp_query->is_feed(  json  ) ) {
        $limits =  LIMIT 50 ;
    }
    return $limits;
}
问题回答

暂无回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签