如何在wordpress主题中以编程方式设置页脚图标?

时间:2017-09-06 13:06:12

标签: wordpress icons footer

我想在二十七个主题中以编程方式设置页脚图标,我创建了一个页面,用于add_menu_page并将其包含在function.php中,我希望在定义任何图标的链接时显示该图标在页脚中,任何人都可以帮我解决这个问题吗?我在这里包含我的自定义页面代码:

<?php 

function theme_options_panel(){
  add_menu_page('Theme page title', 'My Setting', 'manage_options', 'theme-options', 'wps_theme_func');
  add_submenu_page( 'theme-options', 'Settings page title', 'Demo menu', 'manage_options', 'theme-op-settings', 'wps_theme_func_settings');
  add_submenu_page( 'theme-options', 'FAQ page title', 'FAQ menu', 'manage_options', 'theme-op-faq', 'wps_theme_func_faq');
}
add_action('admin_menu', 'theme_options_panel');

function wps_theme_func(){?>
        <form action="" id="frontpostform" method="post" style="margin: 7% 0% 0% 10%;" >
            <h1> Custom Footer icon Setting </h1> <br/>

            <label>Footer facebook Icon url: </label>
            <input type="text" name="name" id="name" value="http://" required="required"> <br/><br/> 

            <label>Footer Twitter Icon url: </label>
            <input type="text" name="name" id="name" value="http://" required="required"> <br/><br/>

            <label>Footer instagram Icon url: </label>
            <input type="text" name="name" id="name" value="http://" required="required"> <br/><br/>

            <label>Footer google+ Icon url: </label>
            <input type="text" name="name" id="name" value="http://" required="required"> <br/><br/>

            <input type="submit" name="submit" value="Submit" style="margin-left: 10%">
    </form> 
<?php }


function wps_theme_func_settings(){
                echo '<div class="wrap"><div id="icon-options-general" class="icon32"><br></div>
                <h2>Demo text</h2></div>';
}


function wps_theme_func_faq(){
                echo '<div class="wrap"><div id="icon-options-general" class="icon32"><br></div>
                <h2>FAQ</h2></div>';
}

1 个答案:

答案 0 :(得分:2)

现在只需将数据保存在wp_option表中,然后在页脚中将其恢复。

用于保存数据

add_action('init','saveCustomData');
function saveCustomData()
{
  if(!is_admin()){
    return;
  }
 if(isset($_REQUEST['submit']))
 {
    //change the name in your html 
    update_option('name',$_REQUEST['name'],true);
 }
}

现在要在页脚中显示,请转到footer.php,然后写下代码

echo get_option('name'); 

注意:您需要为每个html字段执行相同的操作。我只给出了这个例子。