В настоящее время я могу показывать дочерние страницы в качестве вспомогательной навигации на страницах, но не могу показать ее в отдельных представлениях на Wordpress.
Позвольте мне объяснить это подробнее:
- Я создал
sidebar.php
с этим кодом:
<div class="side-menu-wrap">
<?php if(!$post->post_parent) {
$children = wp_list_pages("sort_column=menu_order&title_li=&child_of=".$post->ID."&echo=0");
} else {
if($post->ancestors) {
$ancestors = end($post->ancestors);
$children = wp_list_pages("sort_column=menu_order&title_li=&child_of=".$ancestors."&echo=0");
}
}
if ($children) { ?>
<ul class="side-menu"> <?php echo $children; ?></ul>
<?php } ?>
<div class="home-link">
<a href="<?php bloginfo('url') ?>">ANA SAYFA</a>
</div>
</div>
Создал файл для моего пользовательского типа записи с именем
general-assembly-resolutions.php
и включил
sidebar.php
, например:
<?php /* Template Name: Genel Kurul Kararları */ ?>
<?php get_header(); ?>
<?php include("includes/ui/subpage-header.php"); ?>
<div class="content">
<?php include ("includes/ui/sidebar.php"); ?>
<?php include ("includes/ui/page-toolbar.php"); ?>
<div class="main">
<h2><?php _e("Yeminli Mali Müşavir Raporları", "ceis") ?></h2>
<table class="report-table general-assembly-resolutions-table">
<?php
if ( get_query_var('paged') ) $paged = get_query_var('paged');
if ( get_query_var('page') ) $paged = get_query_var('page');
$query = new WP_Query( array(
'post_type' => 'general-assembly-res',
'paged' => $paged,
'posts_per_page' => -1 )
);
if ( $query->have_posts() ) : ?>
<?php while ( $query->have_posts() ) : $query->the_post(); ?>
<tr>
<td class="report-table__title">
<?php the_title(); ?>
</td>
<td class="report-table__year">
<?php the_field('general_assembly_resolutions_year'); ?>
</td>
<td class="report-table__file">
<a href="<?php the_permalink() ?>"><?php _e("Detayları Görüntüle", "ceis") ?></a>
</td>
</tr>
<?php endwhile; wp_reset_postdata(); ?>
<!-- show pagination here -->
<?php else : ?>
<!-- show 404 error here -->
<?php endif; ?>
</table>
</div><!-- end main -->
</div><!-- end content -->
<?php get_footer(); ?>
Создал единое представление для этого файла пользовательского типа записи с именем
single-general-assembly-res.php
и снова включил
sidebar.php
:
<?php get_header(); ?>
<?php include("includes/ui/subpage-header.php"); ?>
<div class="content">
<?php while ( have_posts() ) : the_post(); ?>
<?php include ("includes/ui/sidebar.php"); ?>
<?php include ("includes/ui/page-toolbar.php"); ?>
<div class="main">
<h2><?php the_title() ?></h2>
<?php the_content() ?>
<div class="attachments">
<h3><?php _e("Bu sayfaya ait dosya ekleri", "ceis") ?></h3>
<table class="report-table general-assembly-resolutions-table">
<!-- <tr>
<td class="report-table__title">
<?php the_title(); ?>
</td>
<td class="report-table__year">
<?php the_field('general_assembly_resolutions_year'); ?>
</td>
<td class="report-table__file">
<a href="<?php the_permalink() ?>"><?php _e("Detayları Görüntüle", "ceis") ?></a>
</td>
</tr> -->
</table>
</div><!-- end .attachments -->
</div>
<?php endwhile; ?>
</div><!-- end content -->
<?php get_footer(); ?>
Так что я могу отобразить подменю на странице просмотр , но не удается отобразить подменю в одиночном просмотре .Что с ним не так?