2016-12-08 3 views
1

Я создал шаблон и добавил строку кода отображения пользовательского типа сообщений, но я не смог получить боковую панель.Пользовательский тип сообщения WordPress шаблон, как добавить пользовательскую боковую панель в шаблоне WordPress

Вот некоторые из кода, который я добавил к моему page-movie-reviews.php файла:

<?php 
/*<?php Template Name: Movie Reviews */ ?> 
<?php get_header();?> 
<?php 
$query = new WP_Query(array('post_type' => 'movie-reviews', 'posts_per_page' => 5)); 
while ($query->have_posts()) : $query->the_post(); ?> 
<div class="cusomt-title"> 
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> 
</div> 
<?php the_post_thumbnail(array(100, 100)); // Other resolutions (height, width) ?> 
<?php the_content(); ?> 
<?php the_excerpt(); ?> 
<?php echo apply_filters('the_content',$mypost->post_content); ?> 
<?php endwhile; ?> 
<?php wp_reset_postdata(); ?> 
<?php get_sidebar(); ?> 
<?php get_footer(); ?> 

ответ

2

первый в нижней части файла функции

<?php 
/** 
* Register our sidebars and widgetized areas. 
* 
*/ 
function movie_widgets_init() { 

    register_sidebar(array(
     'name'   => 'Movie right sidebar', 
     'id'   => 'mome_right_1', 
     'before_widget' => '<div>', 
     'after_widget' => '</div>', 
     'before_title' => '<h2>', 
     'after_title' => '</h2>', 
    )); 

} 
add_action('widgets_init', 'movie_widgets_init'); 
?> 

https://codex.wordpress.org/Widgetizing_Themes

и отображения на боковой панели

<?php 
/*<?php Template Name: Movie Reviews */ ?> 
<?php get_header();?> 
<?php 
$query = new WP_Query(array('post_type' => 'movie-reviews', 'posts_per_page' => 5)); 
while ($query->have_posts()) : $query->the_post(); ?> 
<div class="cusomt-title"> 
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> 
</div> 
<?php the_post_thumbnail(array(100, 100)); // Other resolutions (height, width) ?> 
<?php the_content(); ?> 
<?php the_excerpt(); ?> 
<?php echo apply_filters('the_content',$mypost->post_content); ?> 
<?php endwhile; ?> 
<?php wp_reset_postdata(); ?> 
<?php if (is_active_sidebar('mome_right_1')) : ?> 
    <?php dynamic_sidebar('mome_right_1'); ?> 
<?php endif; ?> 
<?php get_footer(); ?> 
Смежные вопросы