Single.php中的Wordpress Gallery短代码

Single.php中的Wordpress Gallery短代码,php,wordpress,Php,Wordpress,我已经将内容从一个Wordpress站点导出到另一个站点。 我想在wordpress single.php模板文件中显示图库图像(附在每篇文章中) 我已将其添加到single.php中,以显示与每篇文章相关联的图库图像: <?php $gallery_shortcode = '[gallery id="' . intval( $post->post_parent ) . '"]'; print apply_filters( 'the_content', $galle

我已经将内容从一个Wordpress站点导出到另一个站点。 我想在wordpress single.php模板文件中显示图库图像(附在每篇文章中)

我已将其添加到single.php中,以显示与每篇文章相关联的图库图像:

 <?php
    $gallery_shortcode = '[gallery id="' . intval( $post->post_parent ) . '"]';
    print apply_filters( 'the_content', $gallery_shortcode );
 ?>

但是,这显示了wordpress中的所有图像,而不仅仅是链接到每篇文章的图像

我的代码可能不正确,还是从其他站点导入的图片不再链接到每个帖子

这是我的“single.php”文件的全部内容:

<?php
/**
 * The template for displaying all single posts
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post
 *
 * @package WordPress
 * @subpackage Twenty_Seventeen
 * @since 1.0
 * @version 1.0
 */

get_header(); ?>


<div class="wrap">
    <div id="primary" class="content-area">
        <main id="main" class="site-main" role="main">



            <?php
                /* Start the Loop */
                while ( have_posts() ) : the_post();

                    get_template_part( 'template-parts/post/content', get_post_format() );


                    // If comments are open or we have at least one comment, load up the comment template.
                    if ( comments_open() || get_comments_number() ) :
                        comments_template();
                    endif;


                    the_post_navigation( array(
                        'prev_text' => '<span class="screen-reader-text">' . __( 'Previous Post', 'twentyseventeen' ) . '</span><span aria-hidden="true" class="nav-subtitle">' . __( 'Previous', 'twentyseventeen' ) . '</span> <span class="nav-title"><span class="nav-title-icon-wrapper">' . twentyseventeen_get_svg( array( 'icon' => 'arrow-left' ) ) . '</span>%title</span>',
                        'next_text' => '<span class="screen-reader-text">' . __( 'Next Post', 'twentyseventeen' ) . '</span><span aria-hidden="true" class="nav-subtitle">' . __( 'Next', 'twentyseventeen' ) . '</span> <span class="nav-title">%title<span class="nav-title-icon-wrapper">' . twentyseventeen_get_svg( array( 'icon' => 'arrow-right' ) ) . '</span></span>',
                    ) );

                endwhile; // End of the loop.
            ?>

<?php
    $gallery_shortcode = '[gallery id="' . intval( $post->post_parent ) . '"]';
    print apply_filters( 'the_content', $gallery_shortcode );
 ?>
        </main><!-- #main -->
    </div><!-- #primary -->
    <?php get_sidebar(); ?>
</div><!-- .wrap -->

<?php get_footer();


我想。。。未与帖子链接的帖子。。。如何导入数据(1:import DB,2:tools=>import)@deemi I使用1在节中导入。tools=>import,-不确定数据库本身是否已导入。是否有一个插件可以用于导出而不是导入?wordpress tools=>imported always mis the images我通过将图像手动“附加”到帖子来测试我的代码-它仍然会显示wordpress中的所有图像,而不仅仅是我手动附加到帖子上的一个图像?