adding dropdown menu text
authorAnthony Talarico <talarico@gaslightmedia.com>
Thu, 25 Jan 2018 21:36:39 +0000 (16:36 -0500)
committerAnthony Talarico <talarico@gaslightmedia.com>
Thu, 25 Jan 2018 21:36:39 +0000 (16:36 -0500)
adding excerpt display for the dropdown menus

functions.php
inc/menu-walker.php

index 931a500..9220d7d 100644 (file)
@@ -42,7 +42,7 @@ function wmta_setup() {
         * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
         */
        add_theme_support( 'post-thumbnails' );
-
+       add_post_type_support('page','excerpt');
        // This theme uses wp_nav_menu() in one location.
        register_nav_menus( array(
                'primary' => esc_html__( 'Primary Navigation', 'wmta' ),
index 21e8081..240902b 100644 (file)
@@ -45,12 +45,27 @@ class Glm_Theme_Top_Bar_Walker extends Walker_Nav_Menu {
             position: absolute;
             left: 15px;
             top: 15px;
-            
             }
             </style>";
+            
         } else {
             $item_style .= "<style>#menu-item-".$object->ID." > .sub-menu:before { background-image: none; } #menu-item-".$object->ID." > .sub-menu { padding-top: 21px;}</style>";
         }
+        $excerpt = has_excerpt($object->object_id);
+        if($depth == 0 && $excerpt){
+            $the_excerpt = get_the_excerpt($object->object_id);
+            $item_style .= "<style>
+            .menu-item-".$object->ID." > .submenu:after{
+            display: inline-block;
+            height: 100px;
+            content: '$the_excerpt ';
+            position: absolute;
+            font-size: 12px;
+            left: 15px;
+            top: 125px;
+            }
+            </style>";
+        }
         //$output .= ( 0 == $depth ) ? '<li class="divider"></li>' : '';
         $classes = empty( $object->classes ) ? array() : (array) $object->classes;
         if ( in_array( 'label', $classes ) ) {