【问题标题】:Add description feature to wordpress theme为 wordpress 主题添加描述功能
【发布时间】:2016-08-29 11:02:29
【问题描述】:

我的 wordpress 主题中有一个部分是我从头开始的,在那个部分中我有一个标题、标语和描述。

我正在使用:

标题:

get_bloginfo();

对于标语:

get_bloginfo('description');

我需要一种方法,让用户可以编写更长的网站描述并显示它。

我只在谷歌上找到了如何添加元描述,但这不是我想要的。

【问题讨论】:

    标签: php wordpress


    【解决方案1】:

    Wordpress 将这些信息保存在 options 表中。你可以为你做同样的事情。在 wordpress 文档中查看以下函数:

    您需要有一个唯一的 key 名称,例如 desc_long,您将仅将其用于此目的。

    这里是一些示例 sn-p 代码:

    // to save the value in database
    update_option('desc_long', $_POST['input_field_name_in_form']);
    
    // to remove the value from database
    delete_option('desc_long');
    
    // in your theme use the following to retrieve the value
    get_option('desc_long');
    

    据我所知,您不能在现有设置页面中添加任何额外功能,管理员可以在其中输入详细描述并保存。如果您已经有任何主题选项页面是放置此功能的好地方,否则您将不得不创建它。

    【讨论】:

    • 我会试试的,首先我需要阅读一些关于如何使主题选项支持的教程。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-01-31
    • 2021-10-25
    • 1970-01-01
    • 1970-01-01
    • 2014-06-21
    • 1970-01-01
    • 2020-12-20
    相关资源
    最近更新 更多