• Resolved neelmodi

    (@neelmodi)


    I managed to change the category taxomies function to reference images instead of words, and this works well on my homepage and post pages. However, for tags or category pages, the system is adding “/category” or “/tag” to the image URL, so the links are broken.

    The site is neelmodi.com

    The function override in the child functions file is:

    /* change category names to icons */
    
    function twentysixteen_entry_taxonomies() {
    	/*$categories_list = get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'twentysixteen' ) );
    	if ( $categories_list && twentysixteen_categorized_blog() ) {
    		printf( '<span class="cat-links"><span class="screen-reader-text">%1$s </span>%2$s</span>',
    			_x( 'Categories', 'Used before category names.', 'twentysixteen' ),
    			$categories_list
    		);
    	}
    	*/
    
    	foreach((get_the_category()) as $category) {
        echo '<img src="../wp-content/uploads/category-icons/' . $category->cat_name . '.png" class="category-icon" width="45" height="45" alt="' . $category->cat_name . '" />';
    }
    
    	$tags_list = get_the_tag_list( '', _x( ', ', 'Used between list items, there is a space after the comma.', 'twentysixteen' ) );
    	if ( $tags_list ) {
    		printf( '<span class="tags-links"><span class="screen-reader-text">%1$s </span>%2$s</span>',
    			_x( 'Tags', 'Used before tag names.', 'twentysixteen' ),
    			$tags_list
    		);
    	}
    }

    I’m not a PHP expert by any means, so I’m not sure why the category and tag pages are using a different link if it’s using this function.

    Any help would be appreciated

    Thanks

    Neel

Viewing 1 replies (of 1 total)
  • Thread Starter neelmodi

    (@neelmodi)

    I resolved this by using an absolute link to the image folder, rather than relative. Still not sure why WP was putting “/tag” or “/category” in the link, but it works now.

Viewing 1 replies (of 1 total)
  • The topic ‘Changing category indicators to images’ is closed to new replies.