2017-03-21 8 views
1

PHPについてよくわかりません。私は私のWordpressのテーマの設定ページを作成しています。私はfunction.phpにあるテキストボックスでindex.phpのテキストを変更したいと思います。私はあまりにも多くの方法を試みた。私はindex.phpのタグにname、id、valueを割り当てていますfunction.phpソースのaboutustitleのように。しかし、私はそれをしなかった。どうやってやるの?functions.phpからindex.phpまでのテキストを含めるには

ここに私のコード

<?php 
// create custom plugin settings menu 
add_action('admin_menu', 'my_cool_plugin_create_menu'); 

function my_cool_plugin_create_menu() { 

//create new top-level menu 
add_menu_page('Yankı Tema Ayarlar', 'Tema Ayaları', 'administrator', __FILE__, 'my_cool_plugin_settings_page' , plugins_url('/images/icon.png', __FILE__)); 

//call register settings function 
add_action('admin_init', 'register_my_cool_plugin_settings'); 
} 


function register_my_cool_plugin_settings() { 
//register our settings 
register_setting('my-cool-plugin-settings-group', 'aboutustitle'); 
register_setting('my-cool-plugin-settings-group', 'some_other_option'); 
register_setting('my-cool-plugin-settings-group', 'option_etc'); 
} 

function my_cool_plugin_settings_page() { 
?> 
<div class="wrap"> 
<h1>Tema Ayarları</h1> 
    <p>Tema ayarlarınızı buradan düzenleyebilirsiniz</p> 

<form method="post" action="options.php"> 
    <?php settings_fields('my-cool-plugin-settings-group'); ?> 
    <?php do_settings_sections('my-cool-plugin-settings-group'); ?> 
    <table class="form-table"> 
     <h2>Hakkımızda Kısmı</h2> 
     <tr valign="top"> 
     <th scope="row">Başlık</th> 
     <td><input type="text" name="aboutustitle" value="<?php echo esc_attr(get_option('aboutustitle')); ?>" /></td> 
     </tr> 

     <tr valign="top"> 
     <th scope="row">Açıklama</th> 
     <td><input type="text" name="some_other_option" value="<?php echo esc_attr(get_option('some_other_option')); ?>" /></td> 
     </tr> 
    </table> 

    <?php submit_button(); ?> 

</form> 
</div> 
<?php } ?> 

答えて

0

は正確にあなたがここに

を何を意味するのか知らないが、あなたが何かを含める場合、これは私のインデックスのphpであるあなたは、例えば、この

<?php include 'functions.php';?> 

を使用することができます

<!DOCTYPE html> 
<html> 
<body> 

<h1>Welcome to my home page!</h1> 
<?php include 'functions.php'; 
echo "I have a $color $car."; 
?> 

</body> 
</html> 

、私の機能では、PHP

<?php  
$color = "red" 
$car = "BMW" ?> 

ので、出力はあなたが使用してWordpressの中にオプションをエコーすることができます

I have a red BMW 
+0

感謝を。つまり、functions.phpとindex.phpがあります。 functions.phpにはカスタムページがあります。このカスタムページには、フォーム内に1つのテキストボイスがあります。このフォームアクションはoption.phpであり、メソッドもpostです。このテキストボックスは、あなたが見るようにいくつかのPHPコードと統合されています。 index.phpには、 '

lorem ipsum dolor sit amet

'があります。今、function.phpにあるこのテキストボックスに何かをタイプし、設定を保存すると、index.phpにあるこのpがtexboxの書き込みに変わります。 – Onur

関連する問題