【问题标题】:edit theme string variables on wordpress dashboard在 wordpress 仪表板上编辑主题字符串变量
【发布时间】:2023-03-31 23:32:01
【问题描述】:

我有一个网站,其中天气参数非常重要。它们显示在每个页面上,管理员应该每天轻松更新它们。

因此,最好将这四个字符串变量放在仪表板上,然后编辑并保存它们。

有没有一种插件方法可以在仪表板中添加一些字符串,然后在主题中输出它们?还是我应该开始学习如何编写我的第一个插件?

感谢您的帮助。

[编辑] 我们有一些插件可以做到这一点,但现在的问题是:

如何在仪表板上将管理插件页面显示为小部件?

【问题讨论】:

标签: php wordpress wordpress-theming


【解决方案1】:

所以该解决方案基于两个插件和一些复制粘贴操作。

  1. 安装:来自http://wordpress.org/plugins/just-wp-variables/ 的 Just Variables 插件
  2. 在 admin > settings > just variables 上创建一些变量
  3. http://wordpress.org/plugins/widget-builder/ 安装 Widget Builder
  4. 从 yourdomain.com/wp-admin/themes.php?page=jv_theme_vars 制作新的小部件并复制粘贴表单
  5. 选择“作为仪表板小部件可用”,保存,然后转到仪表板。

您可以将输入值更改为变量输出,这应该是这样的:

<form action="options.php" method="post">
    <input type="hidden" value="jv_theme_vars" name="option_page"/><input type="hidden" value="update" name="action"/><input type="hidden" value="ded28ad4c4" name="_wpnonce" id="_wpnonce"/><input type="hidden" value="/wp-admin/themes.php?page=jv_theme_vars" name="_wp_http_referer"/>
    <table class="form-table">
        <tr valign="top">
            <th scope="row">Your Variable</th>
            <td><input type="text" style="width: 15em" name="jv_values[your_variable]" value="[justvar code="your_variable"]" class="regular-text"/></td>
        </tr>
    </table>
    <p class="submit"><input type="submit" value="Save" class="button button-primary" id="submit" name="submit"/></p>       
</form>

祝你好运。 :)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-04-12
    • 1970-01-01
    • 1970-01-01
    • 2011-06-13
    • 2012-09-03
    • 1970-01-01
    • 1970-01-01
    • 2014-05-09
    相关资源
    最近更新 更多