我在使用 ACF 插件的 Wordpress 管理员中自动添加新的系列行和系列的新行时遇到问题。我有中继器字段 o1、系列的文本字段 s、嵌套的中继器 o2 和表带的链接字段 e。例如连载教父:我将添加新的连续剧和新的连续剧集。我需要将新的系列剧集和新的剧集行自动添加到我之前创建的所有系列剧和剧集中。我使用类别名称来区分连续剧。我无法编写可以解决它的代码。你能帮我写出有效的代码吗?这是到目前为止的代码:
<?php
if( have_rows('o1') ):
while( have_rows('o1') ): the_row();
?>
<button onclick="myFunction(event)" class="dropbtn"><?php the_sub_field('s'); ?></button>
<div class="dropdown-content">
<?php
if( have_rows('o2') ):
while ( have_rows('o2') ) : the_row();
$link = get_sub_field('e');
if( $link ):
$link_url = $link['url'];
$link_title = $link['title'];
$link_target = $link['target']? $link['target'] : '_self';
?>
<a class="button" href="<?php echo esc_url( $link_url ); ?>" target="<?php
echo esc_attr( $link_target ); ?>"><?php echo esc_html( $link_title ); ?><br></a>
<?php endif;
endwhile;
else :
endif; ?> </div> <?php
endwhile;
endif;
?>
任何帮助深表感谢