Skip to content

Instantly share code, notes, and snippets.

@cfxd cfxd/header.php
Created Oct 25, 2014

What would you like to do?
Roots Navigation with FCF Fields. See
* Assumes:
* 1. You have a FCF field called 'sections'
* 2. Each FCF block has a text sub field called 'section-title'
global $post;
$id = $post->id;
$sections = get_field('sections', $id);
$home_slug = sanitize_title($sections[0]['section-title']);
<header class="banner navbar navbar-default navbar-static-top" role="banner">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<a class="navbar-brand" href="#<?php echo $home_slug; ?>"><?php bloginfo('name'); ?></a>
<?php if(have_rows('sections')) : ?>
<nav class="collapse navbar-collapse" role="navigation">
<ul class="nav navbar-nav">
<?php while(have_rows('sections')) : ?>
<?php the_row(); ?>
<li class="menu-<?php echo sanitize_title(get_sub_field('section-title')); ?>"><a href="#<?php echo sanitize_title(get_sub_field('section-title')); ?>"><?php echo get_sub_field('section-title'); ?></a></li>
<?php endwhile; ?>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.