WP Manifestindependent plugin directory
manifest / content / wp-nav-helper-page-sections

WP Nav Helper - Page Sections

★ 4stars
17composer installs

Install

Download source zip No release zip yet

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.zip

On Packagist as nathanielks/wp-nav-helper-page-sections:

composer require nathanielks/wp-nav-helper-page-sections
No 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:

  1. There's a field with a Field Name of page_sections that is a Repeater field.
  2. page_sections Repeater field has any number of fields, one of them having a Field Name of title.

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

screenshot4

Nav Helper in action

screenshot1 screenshot2 screenshot3