Support » Themes and Templates » Very Advanced custom theme question re featured images for categories

  • wayneconnor

    (@wayneconnor)


    I have a theme called sliding door.
    http://mac-host.com/slidingdoor
    It has 7 images that slide in the header, each being a link to a post.
    So for each ‘slider’ there is an image and a link.

    The links are selected from the wordpress custom menu.
    The images are uploaded via featured image in a post.

    In the previous version it was done with manual ftp uploads, and the links were put in via theme options page, but the theme checkers suggested I do it via thumbnails and custom menus.

    The problem is that categories, which can be selected in the custom menu’s, don’t have featured images. Is there a way to assign a featured image to a category???

    Can anyone think of another way round this problem?

    Wayne

Viewing 3 replies - 1 through 3 (of 3 total)
  • wayneconnor

    (@wayneconnor)

    PS

    the code for the header is this:

    <div id="imageMenu">
    				<?php
    				$walker = new My_Walker;
    				wp_nav_menu( array(
    				'theme_location' => 'custom-sliding-menu',
    				'fallback_cb' => 'no_sliding_menu',
    				'container' => '',
    				'container_class' =>'',
    				'container_id' =>'',
    				'menu_class' =>'',
    				'menu_id' =>'',
    				'depth' => '1',
    				'walker' => $walker
    				)
    				); ?>
    
    			</div>
    wayneconnor

    (@wayneconnor)

    the code for my walker is this:

    class My_Walker extends Walker_Nav_Menu
    {
    var $item_count = 0;
    
    function end_el(&$output, $item, $depth) {
    		$output .= "";
    	}
    
    	/**
    	 * @param string $output Passed by reference. Used to append additional content.
    	 * @param object $item Menu item data object.
    	 * @param int $depth Depth of menu item. Used for padding.
    	 * @param int $current_page Menu item ID.
    	 * @param object $args
    	 */
        function start_el(&$output, $item, $depth, $args) {
            global $wp_query,$item_count;
            $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
    
            $class_names = $value = '';
    
            $classes = empty( $item->classes ) ? array() : (array) $item->classes;
    		$classes[] = 'menu-item-' . $item->ID;
    
    		if($item_count <= 5){
    			if(isset($item->object_id)) {
    			<strong>$thumbnailid = (int)$item->object_id;
    			$thumbnail = get_the_post_thumbnail_url( $thumbnailid );</strong>
    			} else {
    			$thumbnail = 'http://mac-host.com/slidingdoor/slidingdoor.jpg';
    			}
    
            $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
            $class_names = ' class="bk'.(int)$item_count.'" ';
    
            $output .= $indent . '<li id="menu-item-'. $item->ID . '"' . $value . $class_names .'>';
    
    		$attributes = ! empty( $item->url )        ? ' href="'   . esc_attr( $item->url        ) .'"' : '';
    
    		$item_output = $args->before;
           <strong> $item_output = '<a' . $attributes .' style="background: url(\'' . $thumbnail. '\') repeat scroll 0%;">';</strong>
            $item_output .=  apply_filters( 'the_title', $item->title, $item->ID );
    		$item_output .= '</a>';
     		$item_output .= "</li>\n";
    
            $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
            }
            if($item_count == 6){
    			if(isset($item->object_id)) {
    			$thumbnailid = (int)$item->object_id;
    			$thumbnail = get_the_post_thumbnail_url( $thumbnailid );
    			} else {
    			$thumbnail = 'http://mac-host.com/slidingdoor/slidingdoor.jpg';
    			}
    
             $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
            $class_names = ' class="bk'.(int)$item_count.'" ';
    
     $output .= $indent . '<li class="bk6" id="menu-item-'. $item->ID . '"' . $value . $class_names .'>';
    
    		$attributes = ! empty( $item->url )        ? ' href="'   . esc_attr( $item->url        ) .'"' : '';
    
    		$item_output = $args->before;
            $item_output = '<a' . $attributes .' style="background: url(\'' . $thumbnail. '\') repeat scroll 0%;">';
            $item_output .=  apply_filters( 'the_title', $item->title, $item->ID );
    		$item_output .= '</a>';
     		$item_output .= "</li>\n";
    
            $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
            }
    
        $item_count ++;
    	}
    }

    Hello, I am Brazilian.
    I’m using your theme and would like to know if this problem has a solution.
    I can not link the images to the categories.
    Is there a way?

    I’m still in the testing phase.

    http://blog.cancaonova.com/alemdaneblina

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Very Advanced custom theme question re featured images for categories’ is closed to new replies.