Skip to content

Loop through get_the_category #2

@KittenCodes

Description

@KittenCodes
<?php

	$post_id = get_the_ID();
	//echo $post_id;
	$categories = get_the_category($post_id);

	$cats_output = "";

	foreach ($categories as $category) {
      $slug = $category->slug;
      $name = $category->name;
      $cats_output .= "<a href='/talks/?fwp_categories=" . $slug . "' rel='tag'>" . $name . "</a>,&nbsp;";
      
    }

	$cats_output = substr($cats_output, 0, -7);

	echo $cats_output;

?>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions