• Hi All,

    Is is possible to display the name of blog category minus the link? All I want to display is the name of category below the name of my posts but WordPress automatically applies a URL.

    This is what I have so far:

    <div class="post__inner"> <div class="category__list"> <p class="cat"> <?php echo get_the_category_list(', '); ?> </p> <div class="post__stamp"> <?php the_time('F j, Y'); ?> </div> </div> <div>
Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello,

    If you add this in your functions.php:

    function wporg_category_list(){
    	$get_cat_list = get_the_category();
    	if ( ! empty( $get_cat_list ) ) {
    		$categories = array();
    		foreach ( $get_cat_list as $cat ) {
    			$categories[] = $cat->name;
    		}
    		$categories = implode( ', ', $categories );
    
    		return $categories;
    	}
    }
    

    and then replace

    get_the_category_list(', ');

    with

    wporg_category_list();

    It should do something you need.
    As we’re modifying theme template, I assume you’re running a child theme.

    Thread Starter digstertron

    (@digstertron)

    Hi, sorry for the long delay and many thanks for the advice. I am running my own custom built theme. Cheers. D.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display category title without link.’ is closed to new replies.