Невозможно получить несколько избранных изображений WordPress

Я использовал плагин с несколькими избранными изображениями.

с помощью : Этот плагин

Я следовал инструкциям, приведенным на этой странице.

Я хочу показать изображения на странице ниже заголовка. Добавив этот код ниже в header.php, изображения появятся над заголовком страницы.

 <?php
kdmfi_the_featured_image( 'featured-image-2', 'full' );
kdmfi_the_featured_image( 'featured-image-3', 'full' );
?>

Может кто-нибудь сказать мне, где я должен добавить эту строку в single.php надлежащим образом?

РЕДАКТИРОВАТЬ :

single.php

<?php get_header(); ?>

<div id="primary" class="content-area col-sm-12 col-md-8">
<main id="main" class="site-main" role="main">
<?php
kdmfi_the_featured_image( 'featured-image-2', 'full' );
kdmfi_the_featured_image( 'featured-image-3', 'full' );
?>
<?php
while ( have_posts() ) : the_post();
get_template_part( 'template-parts/content', get_post_format() );
the_post_navigation();
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;

endwhile; // End of the loop.
?>

<?php

kdmfi_the_featured_image( 'featured-image-2', 'full' );

?>

</main><!-- #main -->
</div><!-- #primary -->

<?php
get_sidebar();
get_footer();

header.php:

<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="profile" href="http://gmpg.org/xfn/11">
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
<?php wp_head(); ?>
</head>

<body <?php body_class(); ?>>

<header id="masthead" class="cvit-page-header">
<nav class="navbar navbar-static-top">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only"><?php echo esc_html__('Toggle navigation', 'wp-bootstrap-starter'); ?></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div class="navbar-brand">
<?php if(has_header_image()) :?>
<a href="<?php echo esc_url( home_url( '/' )); ?>" class="site-logo"><img src="<?php header_image(); ?>" height="<?php echo esc_attr(get_custom_header()->height); ?>" width="<?php echo esc_attr(get_custom_header()->width); ?>" alt="<?php esc_url(bloginfo('name')); ?>" /></a>
<?php else: ?>
<a href="<?php echo esc_url( home_url( '/' )); ?>"><?php echo('Technologies'); ?></a><br>
<?php endif; ?>
</div>
</div>

<div id="navbar-collapse" class="collapse navbar-collapse">
<div class="header-content">
<?php
wp_nav_menu( array(
'theme_location'    => 'primary',
'depth'             => 3,
'container'         => '',
'container_class'   => '',
'container_id'      => 'navbar-collapsed',
'menu_class'        => 'nav navbar-nav',
'fallback_cb'       => 'wp_bootstrap_navwalker::fallback',
'walker'            => new wp_bootstrap_navwalker())
);
?>
<div class="navbar-right" role="navigation">
<a href="http://wp-test.dev/products/" class="btn btn-blue">PRODUCTS &amp; SERVICES</a>
</div>
</div>
</div>
</div>
</nav>
</header><!-- #masthead -->

<section id="content" class="site-content cvit-page-section">
<div class="container">
<div class="row">
<?php
kdmfi_the_featured_image( 'featured-image-2', 'full' );
kdmfi_the_featured_image( 'featured-image-3', 'full' );
?>

functions.php

   <?php
add_filter( 'wp_nav_menu_items','add_search_box', 10, 2 );
function add_search_box( $items, $args ) {
$items .= '<li class=”searchbox-position”>' . get_search_form( false ) . '</li>';
return $items;
}

if ( ! function_exists( 'wp_bootstrap_starter_setup' ) ) :

function wp_bootstrap_starter_setup() {

load_theme_textdomain( 'wp-bootstrap-starter', get_template_directory() . '/languages' );

add_theme_support( 'automatic-feed-links' );
add_theme_support('html5', array('search-form'));

add_theme_support( 'title-tag' );

add_theme_support( 'post-thumbnails' );

//For registration of a new featured image please use the handy filter
add_filter( 'kdmfi_featured_images', function( $featured_images ) {
$args = array(
'id' => 'featured-image-2',
'desc' => 'Your description here.',
'label_name' => 'Featured Image 2',
'label_set' => 'Set featured image 2',
'label_remove' => 'Remove featured image 2',
'label_use' => 'Set featured image 2',
'post_type' => array( 'page' ),
);

$featured_images[] = $args;

return $featured_images;
});

add_filter( 'kdmfi_featured_images', function( $featured_images ) {

$args = array(
'id' => 'featured-image-3',
'desc' => 'Your description here.',
'label_name' => 'Featured Image 3',
'label_set' => 'Set featured image 3',
'label_remove' => 'Remove featured image 3',
'label_use' => 'Set featured image 3',
'post_type' => array( 'page' ),
);

$featured_images[] = $args;

return $featured_images;
});

register_nav_menus( array(
'primary' => esc_html__( 'Primary', 'wp-bootstrap-starter' ),
) );

add_theme_support( 'html5', array(
'comment-form',
'comment-list',
'gallery',
'caption',
) );

add_theme_support( 'custom-background', apply_filters( 'wp_bootstrap_starter_custom_background_args', array(
'default-color' => 'ffffff',
'default-image' => '',
) ) );

add_theme_support( 'customize-selective-refresh-widgets' );

}
endif;
add_action( 'after_setup_theme', 'wp_bootstrap_starter_setup' );

function wp_bootstrap_starter_content_width() {
$GLOBALS['content_width'] = apply_filters( 'wp_bootstrap_starter_content_width', 1170 );
}
add_action( 'after_setup_theme', 'wp_bootstrap_starter_content_width', 0 );function wp_bootstrap_starter_widgets_init() {
register_sidebar( array(
'name'          => esc_html__( 'Sidebar', 'wp-bootstrap-starter' ),
'id'            => 'sidebar-1',
'description'   => esc_html__( 'Add widgets here.', 'wp-bootstrap-starter' ),
'before_widget' => '<section id="%1$s" class="widget %2$s">',
'after_widget'  => '</section>',
'before_title'  => '<h3 class="widget-title">',
'after_title'   => '</h3>',
) );
}
add_action( 'widgets_init', 'wp_bootstrap_starter_widgets_init' );

function wp_bootstrap_starter_scripts() {

wp_enqueue_style( 'default', get_template_directory_uri() . '/assets/stylesheets/default.css' );
wp_enqueue_script( 'html5hiv',get_template_directory_uri().'/js/html5.js', array(), '3.7.0', false );
wp_script_add_data( 'html5hiv', 'conditional', 'lt IE 9' );

wp_enqueue_script('jquery', get_template_directory_uri() . '/bower_components/jquery/dist/jquery.min.js', array() );
wp_enqueue_script('bootstrap', get_template_directory_uri() . '/bower_components/bootstrap-sass/assets/javascripts/bootstrap.min.js', array() );if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'wp_bootstrap_starter_scripts' );

require get_template_directory() . '/inc/template-tags.php';

require get_template_directory() . '/inc/extras.php';

require get_template_directory() . '/inc/customizer.php';

require get_template_directory() . '/inc/jetpack.php';

if ( ! class_exists( 'wp_bootstrap_navwalker' )) {
require_once(get_template_directory() . '/inc/wp_bootstrap_navwalker.php');
}

0

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы [email protected]