English 中文(简体)
只有在《刑法》中加入“变换”?
原标题:Adding Ability To Change Only Given Category In This Code?

我最近为我的言论自由网站制定了这一法典。 这使得未登记的用户无法在15天内找到最新的员额,除非他们登记。 它发挥了作用,但我只需要限制我的语音安装中的一个特定类别,而不是所有类别(即我需要限制这一类别,而不是我的博客员额)。

谁能告诉我,需要什么东西才能使这一守则发挥这种作用? 感谢。

    add_filter( posts_where ,  _custom_s2member_archive_filter );
function _custom_s2member_archive_filter($where) /* Require membership to view latest content. */
    {
        if(!is_admin() && (is_archive() || is_home()) && !current_user_can("access_s2member_level1"))
            {
                $where .= " AND post_date <=  ".date ("Y-m-d", strtotime ("-15 days"))." "; /* Back-date freeloaders. */
            }
        return $where;
    }
add_filter( template_redirect ,  _custom_s2member_single_filter );
function _custom_s2member_single_filter() /* Require membership to view latest content. */
    {
        global $post; /* Need this for date comparison. */
        if(!is_admin() && is_single() && !current_user_can("access_s2member_level1"))
            {
                if(strtotime($post->post_date) > strtotime("-15 days"))
                    {
                        header("Location: ".S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL);
                        exit();
                    }
            }
    }
问题回答

首先是确定所涉类别中的哪一个。 你们可以这样做,去“邮局”和“Aminsidebar”的地块,然后点击你试图限制的类别。 在新网页上的URL将最终在标签_ID=[一些编号]上。 该类别为“身份识别”。

Then use Wordpress s conditional tags to write an if statement like
if(is_category( [some number] ))
{
Put the code you already have for restricting the posts here
}

顺便说一句,我没有测试我本人,但让我知道它如何发挥作用!





相关问题
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 ...

热门标签