Results 1 to 4 of 4
-
17th Apr 2012, 06:07 PM #1OPMemberWebsite's:
goathiphop.comHow can I only display the subcategory?
I've spent the last couple of hours on google and found about 20 different ways of doing this but none seem to work.
Each page has a different MP3. At the top of the page I have the Title, Artist, Album, Year, etc.
Artist displays the Category (the alphabet letter related to the Name) and Sub-category (name of the Artist)
Below I have an example:
I would like to display only the Name (sub-category) and leave out the main category.
This is the original code that displays both Cat + Sub:
PHP Code:<tr>
<td width="20%">
<strong><?php _e('Artist','mp3_det'); ?></strong>
</td>
<td>
<?php the_category(', '); ?>
</td>
</tr>
PHP Code:<?php
if($post->post_parent)
$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
if ($children) { ?>
<ul>
<?php echo $children; ?>
</ul>
<?php } ?>PHP Code:<?php
if (is_category()) {
$this_category = get_category($cat);
}
?>
<?php
if($this_category->category_parent)
$this_category = wp_list_categories('orderby=id&show_count=0
&title_li=&use_desc_for_title=1&child_of='.$this_category->category_parent.
"&echo=0"); else
$this_category = wp_list_categories('orderby=id&depth=1&show_count=0
&title_li=&use_desc_for_title=1&child_of='.$this_category->cat_ID.
"&echo=0");
if ($this_category) { ?>
<ul>
<?php echo $this_category; ?>
</ul>
<?php } ?>PHP Code:$echo = '<ul>' . "\n";$childcats = get_categories('child_of=' . $cat . '&hide_empty=1');foreach ($childcats as $childcat) { if (1 == $childcat->category_parent) { $echo .= "\t" . '<li><a href="' . get_category_link($childcat->cat_ID).'" title="' . $childcat->category_description . '">'; $echo .= $childcat->cat_name . '</a>'; $echo .= '</li>' . "\n"; }}$echo .= '</ul>' . "\n";echo $echo;
Does anyone know what I can do to make this work?
Thanksf4n3 Reviewed by f4n3 on . How can I only display the subcategory? I've spent the last couple of hours on google and found about 20 different ways of doing this but none seem to work. Each page has a different MP3. At the top of the page I have the Title, Artist, Album, Year, etc. Artist displays the Category (the alphabet letter related to the Name) and Sub-category (name of the Artist) Below I have an example: http://i1208.photobucket.com/albums/cc364/f4n3/nicki.png I would like to display only the Name (sub-category) and leave out the main Rating: 5
-
17th Apr 2012, 07:06 PM #2Member
Hi buddy,
Try this:
Code:<?php foreach((get_the_category()) as $childcat) { if (cat_is_ancestor_of($categoryid, $childcat)) { echo '<a href="'.get_category_link($childcat->cat_ID).'" title="See more in '.$childcat->cat_name.'">'; echo $childcat->cat_name . '</a></li> '; }} ?>
-
17th Apr 2012, 09:14 PM #3OPMemberWebsite's:
goathiphop.comits working
thanks bjskid !
-
18th Apr 2012, 02:30 AM #4
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
Thread Display Help
By tractor3231 in forum vBulletinReplies: 1Last Post: 13th Sep 2011, 12:08 PM -
Help To display Offers
By San143 in forum Web Development AreaReplies: 2Last Post: 15th Aug 2011, 07:11 AM -
Display your work
By Cooper in forum Graphics AreaReplies: 0Last Post: 10th Apr 2011, 07:37 PM -
Display problem
By Th3Kill33r in forum Technical Help Desk SupportReplies: 0Last Post: 13th Nov 2010, 12:02 AM -
How Big Is Your Primary Display?
By Daniel in forum Polling PlazaReplies: 49Last Post: 3rd Aug 2010, 03:33 PM
themaCreator - create posts from...
Version 3.47 released. Open older version (or...