the_category
echo
s content. You will not be able to use string manipulation. No strings are return
ed that you could manipulate. They are just echo
ed immediately.
You could completely filter out a particular category, which seems to be an option, with this:
function cat_filter_wpse_137596($categories) {
foreach ($categories as $k => $c) {
if ('uncategorized' === $c->slug) {
unset($categories[$k]);
}
}
return $categories;
}
You’d use it like:
add_filter('get_the_categories','cat_filter_wpse_137596');
if (is_category() || is_single()) {
the_category("https://wordpress.stackexchange.com/");
if (is_single()) {
echo "https://wordpress.stackexchange.com/" . '<a href="#">' . get_the_title() . '</a>';
}
} elseif (is_page()) {
echo "https://wordpress.stackexchange.com/" . '<a href="#">' . get_the_title() . '</a>';
}
remove_filter('get_the_categories','cat_filter_wpse_137596');
There is no easy way to keep the category and remove the link. You’d need some nasty regex on the the_category
filter.