WordPress 后台有一些可视化的设置选项,这些选项都可以通过 get_option 函数来调用,陌小雨今天来说说 get_option 函数的使用方法:
get_option( string $option, mixed $default = false )
得到的类型取决于设置参数本身的类型。
参数:
$option
(string) (Required) Name of option to retrieve. Expected to not be SQL-escaped.
$default
(mixed) (Optional) Default value to return if the option does not exist.
Default value: false
用中文来说就是前面一个参数是参数的名称,后面一个是没有设置参数值时候的默认值。(终于知道大学为啥要过英语四级了。。。,感觉好有用!)
A concise list of commonly-used options is below。
下面举出一些 wordpress 后台常用的设置选项
'admin_email'
– E-mail address of blog administrator.'blogname'
– Weblog title; set in General Options.'blogdescription'
– Tagline for your blog; set in General Options.'blog_charset'
– Character encoding for your blog; set in Reading Options.'date_format'
– Default date format; set in General Options.'default_category'
– Default post category; set in Writing Options.'home'
– The blog’s home web address; set in General Options.'siteurl'
– WordPress web address; set in General Options.
Warning: This is not the same asget_bloginfo( 'url' )
(which will return the homepage url), but asget_bloginfo( 'wpurl' )
.'template'
– The current theme’s name; set in Presentation.'start_of_week'
– Day of week calendar should start on; set in General Options.'upload_path'
– Default upload location; set in Miscellaneous Options.'users_can_register'
– Whether users can register; set in General Options.'posts_per_page'
– Maximum number of posts to show on a page; set in Reading Options.'posts_per_rss'
– Maximum number of most recent posts to show in the syndication feed; set in Reading Options.
There are many more options available, a lot of which depend on what plugins you have installed.
函数用法举例:
<?php echo get_option('posts_per_page', 20);>
函数返回你后台设置的每页显示多少篇文章,没有设置的话,就默认 20 篇。
你可能对这些文章感兴趣:
- WordPress只允许管理员访问后台仪表盘
- WordPress添加回马枪访问提示,可自定义
- WordPress 检查一篇文章是否存在的两个办法
- WordPress插件推荐:theme-my-login
- 我理解的世界上之最
- wordpress插件推荐:G-prettify前端样式分享
- WordPress免插件去除分类category
- WordPress获取网站根目录、主题目录、插件目录路径和url地址
- WordPress快速建站第四讲:建站中空间购买解析绑定
- 如何继承熊掌号天级收录权益
- 如何防止多说剽窃我们的网站内容
- WordPress文章评论中表情变小最简单的解决方法
- 万网虚拟主机添加https超详细攻略(最新ssl方案)
- xhtml+css基础第4课-列表
如有疑问,请前往问答中心反馈!
反馈