homepage Welcome to WebmasterWorld Guest from 54.204.178.31
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Small Wordpress PHP problem
greencode

5+ Year Member



 
Msg#: 4468659 posted 8:51 am on Jun 23, 2012 (gmt 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.

 

brandozz



 
Msg#: 4468659 posted 4:10 pm on Jun 24, 2012 (gmt 0)

You could us wp_list_categories within a list


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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved