Wordpress:如何在主题自定义中创建带可编辑文本的部分?

时间:2016-04-29 08:08:39

标签: php html wordpress

我正在尝试创建wordpress主题。 在许多预制主题中,您可以编辑主题自定义菜单中某个部分的文本或其他选项。 我为谷歌做了一点但我的结果不是我需要的。 有谁知道如何达到这个目标?

2 个答案:

答案 0 :(得分:0)

您可以创建自己的主题选项页面。此链接将帮助您

https://codex.wordpress.org/Creating_Options_Pages

示例代码

#define TAKE4(a1, a2, a3, a4, a5, ...) a2, a3, a4, a5
#define FILL_PARAMS(...) TAKE4(0, ##__VA_ARGS__, 0, 0, 0, 0)

以下是theme_settings_page函数的代码,用于创建节并添加提交按钮。

 Creating a Theme Settings Page Menu Item
  function theme_settings_page(){}

  function add_theme_menu_item()
  {
   add_menu_page("Theme Panel", "Theme Panel", "manage_options", "theme panel", "theme_settings_page", null, 99);
  }

  add_action("admin_menu", "add_theme_menu_item");

上传徽标

    function theme_settings_page()
    {
    ?>
    <div class="wrap">
    <h1>Theme Panel</h1>
    <form method="post" action="options.php">
        <?php
            settings_fields("section");
            do_settings_sections("theme-options");      
            submit_button(); 
        ?>          
    </form>
    </div>
    <?php
     }

    function logo_display()
     {
     ?>
    <input type="file" name="logo" /> 
    <?php echo get_option('logo'); ?>

答案 1 :(得分:0)

如果您知道CSS和Html只是休会两个步骤

  • 在文本编辑器中打开子主题style.css文件。 (或者跳过 FTP和文本编辑器,然后转到您的WordPress管理区域, 外观=&gt;编辑,然后单击右侧的style.css。
  • 在Google Chrome中打开您的网站,然后打开开发工具(右键单击 并选择“检查元素”)。

如果您不了解php,html,css等,请按照以下链接

click me to customize wordpress

大多数主题都有主题文档,你应该按照主题文档中的步骤来改变主题选项。