Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Plugins 如何过滤文章、页面、存档和其他页面?_Plugins_Wordpress - Fatal编程技术网

Plugins 如何过滤文章、页面、存档和其他页面?

Plugins 如何过滤文章、页面、存档和其他页面?,plugins,wordpress,Plugins,Wordpress,我正在开发一个新插件。在这个插件中,用户可以选择插件的显示位置 如果用户只在post或archives页面中选择,那么我如何才能找到它? 如果我使用add_filter('the_content','function') 然后我的插件将显示所有页面,但如何在单个类别或归档页面中显示这些页面?我们使用: add_过滤器('the_content',函数($content) { is(!is_single()) 返回$content; 返回“这是一篇文章。”。$content; }); 示例代码需

我正在开发一个新插件。在这个插件中,用户可以选择插件的显示位置

如果用户只在post或archives页面中选择,那么我如何才能找到它? 如果我使用
add_filter('the_content','function')

然后我的插件将显示所有页面,但如何在单个类别或归档页面中显示这些页面?

我们使用:

add_过滤器('the_content',函数($content)
{
is(!is_single())
返回$content;
返回“这是一篇文章。

”。$content; });
示例代码需要PHP 5.3+

我们使用:

add_过滤器('the_content',函数($content)
{
is(!is_single())
返回$content;
返回“这是一篇文章。

”。$content; });

示例代码需要PHP5.3+

您可以检查特定的页面是否正在使用这些条件显示

is_page()   //For pages
is_single   //for posts
is_singular //for posts AND pages
is_category //for categories
is_tag()    //for tags
is_404()    //for 404 page
另外,在添加筛选器时不要使用匿名函数始终使用定义的函数

add_filter ('the_content','my_magic_function');
有关模板标记的更完整列表,请访问:

您可以检查特定页面是否正在使用这些条件显示

is_page()   //For pages
is_single   //for posts
is_singular //for posts AND pages
is_category //for categories
is_tag()    //for tags
is_404()    //for 404 page
另外,在添加筛选器时不要使用匿名函数始终使用定义的函数

add_filter ('the_content','my_magic_function');
有关模板标记的更完整列表,请访问:

仅限单个平均贴子页面?是。这些条件有很多种组合,你必须在文档中挖掘一些,以获得对你的情况有用的条件。只有一个平均贴子页?是的。这些条件有很多种组合,您需要在文档中挖掘一些,以获得对您的情况有用的条件。