Created
September 18, 2015 13:14
-
-
Save djave-co/d2f6fd9c20224f2f642d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
/*-------------------------------- | |
|* Grab the sub pages | |
|*------------------------------- */ | |
$sub_pages = new WP_Query( | |
array( | |
'post_parent' => $post->ID, | |
'post_type' => 'page' | |
) | |
); | |
$sub_page_posts = $sub_pages->posts; | |
/*-------------------------------- | |
|* Sort out the tags. | |
|*------------------------------- */ | |
$tag_ids = [ | |
[ | |
'slug' => 'all', | |
'name' => 'All' | |
] | |
]; | |
foreach( $sub_page_posts as $sub_page): | |
$sub_page->tags = get_the_tags( $sub_page->ID ); | |
/*-------------------------------- | |
|* Create an empty var to hold | |
|* all the slugs to add as a class | |
|*------------------------------- */ | |
$sub_page->tag_classes = ['filterable']; | |
if($sub_page->tags): | |
foreach($sub_page->tags as $tag): | |
/*-------------------------------- | |
|* Add the tag to the var | |
|*------------------------------- */ | |
$sub_page->tag_classes[] = $tag->slug; | |
/*-------------------------------- | |
|* And, if we don't have it, | |
|* store what we need for the menu | |
|*------------------------------- */ | |
if( ! array_key_exists($tag->term_id, $tag_ids)): | |
$tag_ids[$tag->term_id] = [ | |
'slug' => $tag->slug, | |
'name' => $tag->name | |
] ; | |
endif; | |
endforeach; | |
endif; | |
endforeach; | |
?> | |
<div class="sidebar-module"> | |
<h6>Categories</h6> | |
<nav class="no-bullets side-ruled-menu"> | |
<ul id="filters"> | |
<?php if($tag_ids): ?> | |
<?php foreach($tag_ids as $tag): ?> | |
<li><a href="<?php echo home_url('/') . '?tag=' . $tag['slug'] ;?>" data-tag="<?php echo $tag['slug']; ?>"><?php echo $tag['name']; ?></a></li> | |
<?php endforeach; ?> | |
<?php endif; ?> | |
</ul> | |
</nav> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment