Install
This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/nathanielks/wp-nav-helper-page-sections/archive/refs/heads/master.zipOn Packagist as nathanielks/wp-nav-helper-page-sections:
composer require nathanielks/wp-nav-helper-page-sectionsNo built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.
This plugin is designed to work with Advanced Custom Fields. It will allow you to select a page and then create links to a section on that page, assuming that page has ACF meta that follows a certain schema:
- There's a field with a Field Name of
page_sectionsthat is a Repeater field. page_sectionsRepeater field has any number of fields, one of them having a Field Name oftitle.
The plugin will create a link that includes a sanitized copy of the title. The title is passed through WordPress' sanitize_title function. The link will include the url of the page, so you can link to other pages.
You will also need to add that id property to the section on the page. Let's use this loop for an example:
<?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;
?>
Screenshots
ACF Field Group

Nav Helper in action
