简体   繁体   English

wordpress-功能问题

[英]wordpress- trouble in function

I have a problem with this code:我对这段代码有问题:

<?php 
    if (is_home()) $args=array(
        'showposts'=> (int) get_option('13floor_homepage_posts'),
        'paged'=>$paged,
        'category__not_in' => (array) get_option('13floor_exlcats_recent'),
    ); 
?>

I am unable to find this term: 13floor_homepage_posts in the whole theme file.我在整个主题文件中找不到这个词: 13floor_homepage_posts From the codex I have found about get_option从我发现的关于get_option

A safe way of getting values for a named option from the options database table.从选项数据库表中获取命名选项值的安全方法。 If the desired option does not exist, or no value is associated with it, FALSE will be returned."如果所需的选项不存在,或者没有与之关联的值,则将返回 FALSE。”

After that I've searched in the wordpress database but could not find 13floor_homepage_posts and 13floor_exlcats_recent之后,我在 wordpress 数据库中搜索,但找不到13floor_homepage_posts13floor_exlcats_recent

Can anyone please explain this to me谁能给我解释一下

Theget_option method in WordPress will query the {wp-prefix}_options table for a row with the key supplied, in your case '13floor_homepage_posts'. WordPress 中的get_option方法将在{wp-prefix}_options表中查询提供键的行,在您的情况下为“13floor_homepage_posts”。 As you stated from the documentation if not found then FALSE is returned, this means if you queried your options table and did not find it then the response will be false.正如您在文档中所述,如果未找到,则返回FALSE ,这意味着如果您查询了选项表但没有找到它,则响应将为假。 Which in the case of the code snippet you posted I assume will be running against a post query and the showposts parameter when set to false will show all posts.在您发布的代码片段的情况下,我假设将针对帖子查询运行,并且设置为 false 时的showposts参数将显示所有帖子。 So if your theme has an admin console/configuration section I assume it will also have a way to set the value as a setting.因此,如果您的主题有一个管理控制台/配置部分,我认为它也可以将值设置为设置。

As an asside, considering the fact that the code is using showposts instead of its replacement posts_per_page I assume this theme might be a bit dated when it comes to the code and compatibility with newer versions of WordPress/ posts_per_page ,考虑到代码使用的是showposts而不是它的替代物posts_per_page的事实,我认为这个主题在代码和与新版本 WordPress 的兼容性方面可能有点过时了/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM