WordPress 添加主题选项

Wordpress adding theme option

我创建了一个主题,该主题在 header 中有社交图标,现在我想要一个主题功能,管理员可以在其中 link 他们的个人资料到我主题中的社交图标.我对此进行了研究,但仍然一无所知,直到现在我只能在管理面板 > 外观中添加主题选项菜单,其中有一个用于插入社交 link 的文本框。我正在寻找线索以获取该文本框的值并将其添加到社交图标的锚标记中

你可以使用选项树插件。

https://wordpress.org/plugins/option-tree/

借助于此,您可以创建自己的主题选项。 它有两个菜单

1) option tree located at main menu of WordPress admin panel. with help of option tree you can add settings for theme option.

2) theme option located at under appearance menu named theme option with help of option tree you can add value of your setting fields.

并且在您想要显示主题选项值的代码中,您必须纠正下面给出的小代码。

<?php echo ot_get_option('slug'); ?>

希望这些信息对您有所帮助。

使用插件。试试这个代码。

<?php
   /**

Plugin Name: social icons
Description:this plugin is user for testing
Version: 1.0
Author: dev danidhariya
Author URI: http://www.fb.com/dev.danidhariya.09/

*/

define( 'INFO__PLUGIN_URL', plugin_dir_url( __FILE__ ) );
define( 'INFO__PLUGIN_DIR', plugin_dir_path( __FILE__ ) );

register_activation_hook( __FILE__, 'myplugin_activate' );

function myplugin_activate()
{
 global $wpdb;

$sql = "create table '".$wpdb->dbname."'.`wp_social`( 
   `id` int(5) NOT NULL AUTO_INCREMENT , 
   `Link` varchar(1000) , 
   PRIMARY KEY (`id`)
 )";

require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);
}

add_action('admin_menu', 'add_menu_info');
function add_menu_info()
        {

                    add_menu_page('information', 'Test', 'manage_options', 'info', 'info_fun');
                }

function  info_fun()
    {
    ////add form to summit data in wp_social table in column Link to add ur link.

    }

?>

使用 php 在 Linl 列的 theme.wp_social table 中获取 Ur Link。