Thread Starter
Pete
(@perthmetro)
Can this please be moved to How-To and Troubleshooting, thanks
Moderator
Jan Dembowski
(@jdembowski)
Forum Moderator and Brute Squad
Done. And please do not use the imaginary modalert tag. That’s not how you contact the moderators.
Don’t abuse the correct tag BTW as that will land you in trouble. š
Thread Starter
Pete
(@perthmetro)
sorry about that, I got mixed up with ‘modlook’.. is that the right way to contact a mod for something like this?
Moderator
Jan Dembowski
(@jdembowski)
Forum Moderator and Brute Squad
That is the right tag but to be honest leaving this topic in Hacks would have been fine too and modlook wouldn’t really be necessary.
Both sub-forums get the same visibility and people who take time in How-To and Troubleshooting often see Hacks as well.
Thread Starter
Pete
(@perthmetro)
Cheers thanks for that š
leaving this topic in Hacks would have been fine
I was the one who moved to Hacks as that is specifically a coding help sub-forum and tends to be used by the very people who could come up with a solution. In fact I was hoping to come up with something up myself but got side-tracked by a more urgent issue.
Thread Starter
Pete
(@perthmetro)
Ahhhh, i was wondering why I couldn’t find it in the forum, i thought i was going a bit crazy for a minute there š
Try:
<?php $args = array('taxonomy' => 'XYZ'); ?>
<?php $tax_menu_items = get_categories( $args );
$tax_tot = count( $tax_menu_items ); // count number of items in returned array
$c = 0; // set up a counter;
foreach ( $tax_menu_items as $tax_menu_item ):
$c++; // Increment counter ?>
<a href="<?php echo get_term_link($tax_menu_item,$tax_menu_item->taxonomy); ?>"><?php echo $tax_menu_item->name; ?></a>
if ($c < $tax_tot ) echo ',';
<?php endforeach; ?>
FYI: to locate your posts, just view your profile (top right of every page) for a list of the topics you started and contributed to.
Thread Starter
Pete
(@perthmetro)
Thanks… and yes, that’s how i found out where it was š
No luck with that, this line didn’t highlight correctly in notepad++
if ($c < $tax_tot ) echo ',';
Ugh! My bad!
<?php $args = array('taxonomy' => 'XYZ'); ?>
<?php $tax_menu_items = get_categories( $args );
$tax_tot = count( $tax_menu_items ); // count number of items in returned array
$c = 0; // set up a counter;
foreach ( $tax_menu_items as $tax_menu_item ):
$c++; // Increment counter ?>
<a href="<?php echo get_term_link($tax_menu_item,$tax_menu_item->taxonomy); ?>"><?php echo $tax_menu_item->name; ?></a>
<?php if ($c < $tax_tot ) echo ',';?>
<?php endforeach; ?>
Thread Starter
Pete
(@perthmetro)
ahh added the php tags š
Thread Starter
Pete
(@perthmetro)
Thanks, for that. Much appreciated š
Thread Starter
Pete
(@perthmetro)
Sorry for being pedantic but there is a space before the comma and no space after the comma… I was hoping for it to be the opposite š
<?php $args = array('taxonomy' => 'XYZ'); ?>
<?php $tax_menu_items = get_categories( $args );
$tax_tot = count( $tax_menu_items ); // count number of items in returned array
$c = 0; // set up a counter;
foreach ( $tax_menu_items as $tax_menu_item ):
$c++; // Increment counter ?>
<a href="<?php echo get_term_link($tax_menu_item,$tax_menu_item->taxonomy); ?>"><?php echo $tax_menu_item->name; ?></a>
<?php if ($c < $tax_tot ) echo ', ';?>
<?php endforeach; ?>
Thread Starter
Pete
(@perthmetro)
There is still a space before the comma??
<li><b>Skills: </b><?php $args = array('taxonomy' => 'skill'); ?>
<?php $tax_menu_items = get_categories( $args );
$tax_tot = count( $tax_menu_items ); // count number of items in returned array
$c = 0; // set up a counter;
foreach ( $tax_menu_items as $tax_menu_item ):
$c++; // Increment counter ?>
<a href="<?php echo get_term_link($tax_menu_item,$tax_menu_item->taxonomy); ?>"><?php echo $tax_menu_item->name; ?></a>
<?php if ($c < $tax_tot ) echo ', '; ?>
<?php endforeach; ?></li>