页面子导航未在单个帖子视图中显示

时间:2019-09-22 14:22:00

标签: php wordpress

我目前能够将子页面显示为页面中的子导航,但无法在Wordpress的单个视图中显示。

让我进一步解释一下:

  1. 我使用以下代码创建了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>
  1. 为名为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(); ?>
  1. 为此名为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(); ?>

所以我可以在page view上显示子菜单,但是不能在single view中显示子菜单。怎么了?

0 个答案:

没有答案