From: Steve Sutton Date: Fri, 13 Nov 2015 18:56:08 +0000 (-0500) Subject: WIP breadcrumbs for post pages X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fbreadcrumbs;p=WP-Themes%2FGovernmentEmmet.git WIP breadcrumbs for post pages --- diff --git a/archive.php b/archive.php index c6f873f..6a2a380 100644 --- a/archive.php +++ b/archive.php @@ -2,7 +2,12 @@
id="interior"> -
+ +
+
+ +
+
diff --git a/functions.php b/functions.php index c3a77a3..ce43910 100644 --- a/functions.php +++ b/functions.php @@ -55,14 +55,14 @@ function SearchFilter($query) { add_filter('pre_get_posts','SearchFilter'); add_theme_support('post-thumbnails'); $defaults = array( - 'default-color' => '', - 'default-image' => '', - 'default-repeat' => '', - 'default-position-x' => '', - 'default-attachment' => '', - 'wp-head-callback' => '_custom_background_cb', - 'admin-head-callback' => '', - 'admin-preview-callback' => '' + 'default-color' => '', + 'default-image' => '', + 'default-repeat' => '', + 'default-position-x' => '', + 'default-attachment' => '', + 'wp-head-callback' => '_custom_background_cb', + 'admin-head-callback' => '', + 'admin-preview-callback' => '' ); add_theme_support( 'custom-background', $defaults ); set_post_thumbnail_size(120, 100, true); @@ -208,4 +208,43 @@ function glm_side_menu($mobile = false) { } add_action('wp_enqueue_scripts', 'glm_site_scripts'); + +function glm_blog_bread_crumbs() +{ + global $post; + $post_to_page = array( + 18 => 1257, + 26 => 11786, + 68 => 6963, + 69 => 11783 + ); + $breadcrumbs = array(); + // find out which category this post is in. + if ($post) { + $post_categories = wp_get_post_categories( $post->ID ); + //echo '
' . print_r($post_categories, true) . '
'; + if ($post_to_page[$post_categories[0]]) { + $pageId = $post_to_page[$post_categories[0]]; + $breadcrumbs[] = '' . get_the_title( $pageId ) . ''; + glm_get_menu_ancestors_by_page_id( $pageId ); + } + $breadcrumbs[] = 'Home'; + echo implode(' ', array_reverse($breadcrumbs)); + } +} +function glm_get_menu_ancestors_by_page_id($page) +{ + if ( ( $locations = get_nav_menu_locations() ) && isset( $locations['top-bar'] ) ) { + $menu = wp_get_nav_menu_object( $locations['top-bar'] ); + $menu_items = wp_get_nav_menu_items( $menu->term_id ); + foreach ((array) $menu_items as $key => $menu_item) { + $sideMenu[$menu_item->menu_item_parent][] = $menu_item; + $allMenu[$menu_item->ID] = $menu_item; + if ($menu_item->object_id == $post->ID) { + $pageMenuId[] = $menu_item; + } + } + echo '
' . print_r($sideMenu, true) . '
'; + } +} ?> diff --git a/parts/blog-bread-crumbs.php b/parts/blog-bread-crumbs.php new file mode 100644 index 0000000..ccb17b4 --- /dev/null +++ b/parts/blog-bread-crumbs.php @@ -0,0 +1,7 @@ + + +

+ + diff --git a/single.php b/single.php index be1fed1..0f1c08f 100644 --- a/single.php +++ b/single.php @@ -1,12 +1,15 @@ +
+
+
+ +
+
-