2014-01-21 62 views
0

我知道這個問題之前已經問過,爲什麼不是我的代碼保存,但本教程最近是由用戶在這裏推薦的,我一直在關注它從tuts加上,(顯然改變變量和選項以適應我的需要),但由於某種原因,說設置保存的小酒吧會出現,保存按鈕出現,形式本身,這一切都看起來不錯,但是當我擊中保存,它從形式上消失。請記住,我只嘗試保存第一個選項,網站徽標網址的設置。這是我的代碼,它正確地包含在functions.php文件中。 PS:對不起,它們都在一起,PHP和HTML,但這是唯一的方法,在一篇文章中將它們放在一起,另外,我喜歡在完成後將它們放在單獨的文件中。無法保存主題選項,遵循tutsplus的教程

<?php 
if (!current_user_can('manage_options')) { 
    wp_die('You do not have permission to view this page, if you believe that this is a mistake, please contact your system administrator, or try closing the tab and come back.'); 
} 


add_action("admin_menu", "setup_where_now_admin_menus"); 

function setup_where_now_admin_menus() { 
    add_menu_page('Front Door Theme Options', 'Front Door Theme Options', 'manage_options', 'where_now_elements', 'where_now_options') ; 
} 
?> 

<?php 
function where_now_options() { ?> 
<div class="wrap"> 
<h2>Front Door Web Design Custom Theme Options</h2> 
<form method="post" action=""> 


<h4>Site Logo URL</h4> 
<p>Remember, this is the image used in places like your header, or anywhere else you want your logo to appear, and if you are having trouble remembering how to use this feature, you can always upload your new logo to the media section in Wordpress, get the URL from the specific images page, and then paste it here!</p>  
<input type="text" name="site_logo" value="<?php echo $site_logo;?>" size="25"> 


    <h4>Analytics Tracking Code</h4> 
    <p>Any code used for tracking purposes that is placed in the header goes here</p> 
    <input type="text" name="analytics_code"> 


    <?php 
    $site_logo = get_option("where_now_site_logo"); 

    if (isset($_POST["update_settings"])) { 

    $site_logo = esc_attr($_POST["site_logo"]); 
update_option("where_now_site_logo", $site_logo); 
?> 
<div id="message" class="updated">Your Changes Have Been Saved</div> 
<?php 

} 
    ?> 
    <input type="hidden" name="update_settings" value="Y" /> 

    <input type="submit" value="Save settings" class="button-primary"/> 
</form> 
</div> 
<?php  
} 
?> 

任何想法?

回答

0

我建議你使用這個插件:Option Tree 這是非常簡單的,不需要任何編碼。只需將它安裝在您的網站上,您的主題正在運行,然後您可以輕鬆管理您的選項。

+0

我會研究一下,但我正在製作客戶網站的基本主題。我寧願只編碼它。 – user3219783

+0

我認爲這可以幫助你[選項框架](http://wordpress.org/plugins/options-framework/) – Alireza