Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 504799

Changing category indicators to images

$
0
0

Replies: 0

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 all articles
Browse latest Browse all 504799

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>