Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Small Wordpress PHP problem

8:51 am on Jun 23, 2012 (gmt 0)

Junior Member

10+ Year Member Top Contributors Of The Month

joined:July 4, 2007
posts: 193
votes: 0

In my Wordpress template I have the following code which basically gets the name and link of the sub category of category ID 1 and then echoes that out. I'm sure this is a very very simple PHP issue but I don't know how to get it so that all of it is contained within the link. So it currently looks like this:

View all Art projects (with only "Art" being the link) whereas I want all of "View all Art projects" to be the link

<li><?php _e( 'View all', 'mytheme' ); ?> <?php
foreach((get_the_category()) as $childcat) {
if (cat_is_ancestor_of(1, $childcat)) {
echo '<a href="'.get_category_link($childcat->cat_ID).'">';
echo $childcat->cat_name . '</a>';
?> <?php _e( 'Projects', 'mytheme' ); ?></li>

Thanks in advance for any help.
4:10 pm on June 24, 2012 (gmt 0)

Junior Member

5+ Year Member

joined:June 6, 2012
posts: 104
votes: 0

You could us wp_list_categories within a list

<ul class="subcat-lists">
<php wp_list_categories('title_li=&child_of=1'); ?>