nathanielks / wp-nav-helper-page-sections
0.1.0
2016-08-11 19:35 UTC
Requires
- php: >=5.3
This package is auto-updated.
Last update: 2024-08-29 04:03:34 UTC
README
此插件旨在与高级自定义字段(Advanced Custom Fields)配合使用。它将允许您选择一个页面,然后在该页面的某个部分创建链接,前提是该页面有遵循特定模式的ACF元数据。
- 存在一个名为
page_sections
的字段,它是一个重复字段。 page_sections
重复字段可以有任意数量的字段,其中之一具有名为title
的字段名。
插件将创建一个包含标题清洗副本的链接。标题通过WordPress的 sanitize_title
函数传递。链接将包括页面的URL,因此您可以链接到其他页面。
您还需要将此id属性添加到页面上的部分。以下是一个示例循环
<?php // check if the repeater field has rows of data if( have_rows('page_sections') ): // loop through the rows of data while ( have_rows('page_sections') ) : the_row(); $title_slug = sanitize_title(get_sub_field('title')); ?> <section class="page-section section-<?php echo $title_slug; ?>" id="<?php echo $title_slug; ?>"> <?php // Content stuff here ?> </section> <!-- end .page-section.section-<?php echo $title_slug; ?> --> <?php endwhile; endif; ?>