Coder Social home page Coder Social logo

wp-nav-helper-page-sections's Introduction

WP Nav Helper - Page Sections

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

wp-nav-helper-page-sections's People

Contributors

nathanielks avatar

Stargazers

Michael Keene avatar tobey avatar Alex Patin avatar CFX avatar Ben Word avatar

Watchers

 avatar  avatar James Cloos avatar Evan Agee avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.