我已使用自定义帖子类型创建了图库。我为此使用了画廊块。然后,我尝试将图库块添加到我的single-portfolio.php
中,但找不到解决方法。我发现早期的get_post_galleries()
这段代码可以解决我的问题,但是不能正确使用代码块吗?画廊块有类似的功能吗?
这是我的single-portfolio.php
:
<?php get_header(); ?>
<main>
<div class="project-nav">
<div>
<h4><?php previous_post_link(); ?></h4>
</div>
<div class="project-nav-logo">
<a href="<?php echo get_home_url(); ?>">
<?php
if ( function_exists( 'the_custom_logo' ) ) {
the_custom_logo();
} else {
echo '<h1>'. get_bloginfo( 'name' ) .'</h1>';
}
?>
</a>
</div>
<div>
<h4><?php next_post_link(); ?></h4>
</div>
</div>
<?php $hero = get_field('header_image'); ?>
<section class="project-header"
style="background-image: url('<?php echo $hero['url'] ?>');"
>
<div class="project-header-content">
<?php while ( have_posts() ) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h1 class="project-title"><?php echo the_title(); ?></h1>
</article>
<?php endwhile; ?>
</div>
</section>
<section class="project-text-content">
<div class="project-text">
<?php
$text = get_field('intro_text');
if(!empty ($text)): ?>
<p><?php echo $text; ?></p>
<?php endif; ?>
</div>
</section>
<section class="project-image-content">
<!-- ----------------------------- -->
<!-- Gallery block should be here -->
<!-- --------------------------- -->
</section>
</main>
<?php get_footer(); ?>
谢谢!