Created
October 25, 2014 03:42
-
-
Save cfxd/b46fe1428f5a354495f9 to your computer and use it in GitHub Desktop.
Roots Navigation with FCF Fields. See http://cfxdesign.com/one-page-wordpress-theme-workflows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* | |
* Assumes: | |
* 1. You have a FCF field called 'sections' | |
* 2. Each FCF block has a text sub field called 'section-title' | |
* | |
*/ | |
<?php | |
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> | |
</button> | |
<a class="navbar-brand" href="#<?php echo $home_slug; ?>"><?php bloginfo('name'); ?></a> | |
</div> | |
<?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; ?> | |
</ul> | |
</nav> | |
<?php endif; ?> | |
</div> | |
</header> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment