nathanielks / wp-nav-helper-page-sections

安装: 14

依赖项: 0

建议者: 0

安全: 0

星标: 5

关注者: 4

分支: 0

开放问题: 0

类型:wordpress-plugin

0.1.0 2016-08-11 19:35 UTC

This package is auto-updated.

Last update: 2024-08-29 04:03:34 UTC


README

此插件旨在与高级自定义字段(Advanced Custom Fields)配合使用。它将允许您选择一个页面,然后在该页面的某个部分创建链接,前提是该页面有遵循特定模式的ACF元数据。

  1. 存在一个名为 page_sections 的字段,它是一个重复字段。
  2. 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;
?>

屏幕截图

ACF字段组

screenshot4

导航助手在实际应用中的效果

screenshot1 screenshot2 screenshot3