where did you define $category_id ?
The goal is to find a way to get the link of the category belonging to a post.
that is what <?php the_category(', '); ?> does perfectly;
can you describe why you can’t/won’t use that function?
Oh yeah, failed to copy the whole code…
The problem is now found, yet not the solution.
It would be ideal to use <?php the_category(', '); ?> if it was possible to change the title output:
<a href="<?php the_category(', '); ?>" title="Category Source">/Category Source/</a>
Which it doesn’t want to.
failed to copy the whole code…
please paste the full code into a http://pastebin.com/ and post the link to it here.
example code for getting the categories of a post as links, separated by a space:
<?php $cats = get_the_category($post->ID);
foreach( $cats as $cat ) { ?>
<a href="<?php echo get_category_link($cat->term_id); ?>"><?php echo $cat->name; ?></a>
<?php } ?>
Thanks, that worked out great!
Modified it a bit:
<?php $ep_cats = get_the_category($post->ID);
foreach( $ep_cats as $ep_cat ) { ?>
<a href="<?php echo get_category_link($ep_cat->term_id); ?>" title="<?php $ep_cat->name; ?>">/Category Source/</a> -|
<?php } ?>
For the other code, from before:
<?php
// Get the ID of a given category
$category_id = get_cat_ID( 'Category Name' );
// Get the URL of this category
$category_link = get_category_link( $category_id );
?>
<!-- Print a link to this category -->
<a href="<?php echo $category_link; ?>" title="Category Name">Category Name</a>
From the WordPress codex. As you can see, it relies on a category id, which get_the_category($post->ID) would have worked, I think…
Well, thank you again–for your help!
Suffice, thanks for posting your solution, not everyone does.