Для начала необходимо зарегистрировать новый сайдбар в functions.php после чего создать файл в сайдбаром и наполнить его необходимым. В нужном месте — вывести.
Дело в том, что тот что есть сайдбар не зарегистрирован в functions.php
Вот код
<?php
/** Load the Core Files */
require_once( trailingslashit( get_template_directory() ) . 'lib/init.php' );
new Contango();
/** Do theme setup on the 'after_setup_theme' hook. */
add_action( 'after_setup_theme', 'contango_theme_setup' );
/** Theme setup function. */
function contango_theme_setup() {
/** Add theme support for Feed Links. */
add_theme_support( 'automatic-feed-links' );
/*
* Let WordPress manage the document title.
* By adding theme support, we declare that this theme does not use a
* hard-coded <title> tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
/** Post Formats */
add_theme_support( 'post-formats', array( 'aside', 'audio', 'chat', 'gallery', 'image', 'link', 'quote', 'video' ) );
/** Add theme support for Custom Background. */
add_theme_support( 'custom-background', array( 'default-color' => 'e9e9e9', 'default-image' => '%s/images/bg-pattern.png', 'wp-head-callback' => 'contango_custom_background_callback' ) );
/** Set content width. */
contango_set_content_width( 580 );
/** Add custom image sizes. */
add_action( 'init', 'contango_add_image_sizes' );
}
/** Adds custom image sizes */
function contango_add_image_sizes() {
add_image_size( 'featured', 200, 180, true );
}
/**
* This is a fix for when a user sets a custom background color with no custom background image. What
* happens is the theme's background image hides the user-selected background color. If a user selects a
* background image, we'll just use the WordPress custom background callback.
*
* @link http://core.trac.wordpress.org/ticket/16919
*/
function contango_custom_background_callback() {
/* Get the background image. */
$image = get_background_image();
/* If there's an image, just call the normal WordPress callback. We won't do anything here. */
if ( !empty( $image ) ) {
_custom_background_cb();
return;
}
/* Get the background color. */
$color = get_background_color();
/* If no background color, return. */
if ( empty( $color ) ) {
return;
}
/* Use 'background' instead of 'background-color'. */
$style = "background: #{$color};";
?>
<style type="text/css">body.custom-background { <?php echo trim( $style ); ?> }</style>
<?php
}
Выходит так, что functions.php не отвечает за сайдбарды.
Вы не правы. Посмотрите, что инклюдит файл — init.php, я более, чем уверен, что внутри еще несколько инклюдов, и где-то среди них и регистрируется сайдбар ваш.
https://codex.wordpress.org/Function_Reference/register_sidebar — вот разбор этого момента на кодексе.
Вот файл init.php
<?php
/** Core Theme Framework */
class Contango {
/** Constructor Method */
function __construct() {
/** Define a Global variable Standard Class */
global $contango;
$contango = new stdClass;
/** Define framework, parent theme, and child theme constants. */
add_action( 'after_setup_theme', array( &$this, 'constants' ), 1 );
/** Load the core functions required by the rest of the framework. */
add_action( 'after_setup_theme', array( &$this, 'core' ), 2 );
/** Language functions and translations setup. */
add_action( 'after_setup_theme', array( &$this, 'i18n' ), 3 );
/** Load the framework functions. */
add_action( 'after_setup_theme', array( &$this, 'functions' ), 12 );
/** Load admin files. */
add_action( 'wp_loaded', array( &$this, 'admin' ) );
}
/** Define Constant Paths */
function constants() {
/** Directory Location Constants */
/** Sets the path to the parent theme directory. */
define( 'CONTANGO_DIR', trailingslashit( get_template_directory() ) );
define( 'CONTANGO_LIB_DIR', trailingslashit( CONTANGO_DIR . 'lib' ) );
define( 'CONTANGO_FUNCTIONS_DIR', trailingslashit( CONTANGO_LIB_DIR . 'functions' ) );
define( 'CONTANGO_ADMIN_DIR', trailingslashit( CONTANGO_LIB_DIR . 'admin' ) );
define( 'CONTANGO_JS_DIR', trailingslashit( CONTANGO_LIB_DIR . 'js' ) );
define( 'CONTANGO_CSS_DIR', trailingslashit( CONTANGO_LIB_DIR . 'css' ) );
/** URI Location Constants */
/** Sets the path to the parent theme directory URI. */
define( 'CONTANGO_URI', trailingslashit( get_template_directory_uri() ) );
define( 'CONTANGO_LIB_URI', trailingslashit( CONTANGO_URI . 'lib' ) );
define( 'CONTANGO_ADMIN_URI', trailingslashit( CONTANGO_LIB_URI . 'admin' ) );
define( 'CONTANGO_JS_URI', trailingslashit( CONTANGO_LIB_URI . 'js' ) );
define( 'CONTANGO_CSS_URI', trailingslashit( CONTANGO_LIB_URI . 'css' ) );
}
/** Loads the core framework functions. */
function core() {
/** Load the core framework functions. */
require_once( CONTANGO_FUNCTIONS_DIR . 'core.php' );
}
/** Loads translation files */
function i18n() {
/** Translations can be filed in the /languages/ directory */
load_theme_textdomain( 'contango', CONTANGO_DIR . 'languages' );
}
/** Loads the framework functions. */
function functions() {
/** Load media-related functions. */
require_once( CONTANGO_FUNCTIONS_DIR . 'media.php' );
/** Load utility functions. */
require_once( CONTANGO_FUNCTIONS_DIR . 'utility.php' );
/** Load theme settings functions. */
require_once( CONTANGO_FUNCTIONS_DIR . 'settings.php' );
/** Load menus functions. */
require_once( CONTANGO_FUNCTIONS_DIR . 'menus.php' );
/** Load sidebars functions. */
require_once( CONTANGO_FUNCTIONS_DIR . 'sidebars.php' );
/** Load featured image functions. */
require_once( CONTANGO_FUNCTIONS_DIR . 'featured-image.php' );
/** Load custom header functions. */
require_once( CONTANGO_FUNCTIONS_DIR . 'custom-header.php' );
}
/** Load admin files for the framework. */
function admin() {
/* Check if in the WordPress admin. */
if ( is_admin() ) {
/* Load the main admin file. */
require_once( CONTANGO_ADMIN_DIR . 'admin.php' );
}
}
За сайдбар здесь отвечает эта строка:
require_once( CONTANGO_FUNCTIONS_DIR . 'sidebars.php' );
Но, что это значит?
register_sidebar прописан только в sidebar.php. По крайней мере в других файлах я его найти не могу.