PHP code to echo taxonomy names – PremiumPress Themes https://www.premiumpress.com/forums/topic/php-code-to-echo-taxonomy-names/feed/ Tue, 27 Jan 2026 16:58:27 +0000 https://bbpress.org/?v=2.6.4 en-US https://www.premiumpress.com/forums/topic/php-code-to-echo-taxonomy-names/#post-745 <![CDATA[PHP code to echo taxonomy names]]> https://www.premiumpress.com/forums/topic/php-code-to-echo-taxonomy-names/#post-745 Wed, 03 Jul 2013 22:45:02 +0000 Steve Hello all…I have a taxonomy/PHP question. My DirectoryPress site is using the country/state/city taxonomy (well really just state,city taxonomy as all my listing are USA cities) and I am wanting to print for each free listing on the search results page a standard address block, i.e.:

company name
address line
city, state, zipcode
phone number

I’ve figured out the company, address, zip code and phone number as they are just standard and custom fields, but I’m stumped on how to echo the city and state, they being taxonomies.

Any help with the PHP code would be GREATLY appreciated.

Thanks in advance!

]]>
https://www.premiumpress.com/forums/topic/php-code-to-echo-taxonomy-names/#post-756 <![CDATA[Reply To: PHP code to echo taxonomy names]]> https://www.premiumpress.com/forums/topic/php-code-to-echo-taxonomy-names/#post-756 Wed, 03 Jul 2013 23:48:31 +0000 hi, this is an exemple of _item.php

<br><?php echo "Adresse : "?><?php echo get_post_meta($post->ID, 'adresse', true); ?>
		<br><?php echo "Code postal : "?><?php echo get_post_meta($post->ID, 'cp', true); ?>
		<br><?php echo "Ville : "?><?php echo get_post_meta($post->ID, 'ville', true); ?>
		<br><?php echo "Téléphone : "?><?php echo get_post_meta($post->ID, 'tel', true); ?>
		<br><?php echo "Fax : "?><?php echo get_post_meta($post->ID, 'fax', true); ?>
		<br><?php if($custom1 != "" || $custom2 != ""){  echo '<p class="smalltags">'.get_option("display_custom_display1")." ".$custom1."  ".get_option("display_custom_display2")." ".$custom2.''; } ?>
		<br><?php echo "Catégorie : "?> <?php the_category(' ') ?> 
		<br><?php echo "Mots clés : "?><?php if(get_option("display_search_tags") =="yes"){ the_tags( '', '', ''); } ?>

you do use customs fields, and the key is the name of your custom fields

]]>
https://www.premiumpress.com/forums/topic/php-code-to-echo-taxonomy-names/#post-759 <![CDATA[Reply To: PHP code to echo taxonomy names]]> https://www.premiumpress.com/forums/topic/php-code-to-echo-taxonomy-names/#post-759 Thu, 04 Jul 2013 00:44:26 +0000 Mark Fail thanks for sharing 🙂

]]>
https://www.premiumpress.com/forums/topic/php-code-to-echo-taxonomy-names/#post-912 <![CDATA[Reply To: PHP code to echo taxonomy names]]> https://www.premiumpress.com/forums/topic/php-code-to-echo-taxonomy-names/#post-912 Thu, 04 Jul 2013 15:49:24 +0000 Steve Thanks for the reply Patrick, but I couldn’t get it to work for the city adn state simply by calling it with echo get_post_meta($post->ID, ‘city’, true) – I just get back missing lines for city and state, like the program just skipped over it.

I know Mark mentioned that in importing records that I had to use the column header “location” and the field in the format “California,Los Angeles” (no quotes) and that worked to import city and state. But I’m still stumped on how to echo city and state on screen.

Has anyone else done this besides the creator of the Harrogate site:

https://www.harrogate.co.uk/category/shopping/electricals-appliances/

THAT’s what I’m trying to achieve with my free lsitings, but the creator of that site would never get back to me, for whatever reason. So I’m trying other avenues, with no luck so far. I’m sure it’s probably a very simple line of code for someone more knowledgeable in PHP than I am.

]]>
https://www.premiumpress.com/forums/topic/php-code-to-echo-taxonomy-names/#post-948 <![CDATA[Reply To: PHP code to echo taxonomy names]]> https://www.premiumpress.com/forums/topic/php-code-to-echo-taxonomy-names/#post-948 Thu, 04 Jul 2013 23:02:05 +0000 Hi, you want just display Taxonomies on _item ? (search results page )

]]>
https://www.premiumpress.com/forums/topic/php-code-to-echo-taxonomy-names/#post-949 <![CDATA[Reply To: PHP code to echo taxonomy names]]> https://www.premiumpress.com/forums/topic/php-code-to-echo-taxonomy-names/#post-949 Thu, 04 Jul 2013 23:04:42 +0000 You can try this :
<?php $terms = wp_get_post_terms( $post_id, $taxonomy, $args ); ?>

]]>
https://www.premiumpress.com/forums/topic/php-code-to-echo-taxonomy-names/#post-950 <![CDATA[Reply To: PHP code to echo taxonomy names]]> https://www.premiumpress.com/forums/topic/php-code-to-echo-taxonomy-names/#post-950 Thu, 04 Jul 2013 23:06:43 +0000 Steve Hi Patrick, yes, so that city, state and zip code will show on one line as <span style=”text-decoration:underline;”>Richmond, Virginia 23221</span>

]]>
https://www.premiumpress.com/forums/topic/php-code-to-echo-taxonomy-names/#post-951 <![CDATA[Reply To: PHP code to echo taxonomy names]]> https://www.premiumpress.com/forums/topic/php-code-to-echo-taxonomy-names/#post-951 Thu, 04 Jul 2013 23:10:39 +0000 Steve Patrick, but how exactly would I echo both city and state separated by a comma and then a space?

]]>
https://www.premiumpress.com/forums/topic/php-code-to-echo-taxonomy-names/#post-952 <![CDATA[Reply To: PHP code to echo taxonomy names]]> https://www.premiumpress.com/forums/topic/php-code-to-echo-taxonomy-names/#post-952 Thu, 04 Jul 2013 23:15:07 +0000 hi Steve,
for do it, you can remove in my exemple <br>
and create the custoom fields on your admin.

this the code :

<span style=”text-decoration:underline;”><?php echo "City : "?><?php echo get_post_meta($post->ID, 'city', true); ?>
<?php echo "State : "?><?php echo get_post_meta($post->ID, 'state', true); ?>
<?php echo "ZIP CODE : "?><?php echo get_post_meta($post->ID, 'zip', true); ?></span>

you do just creat 3 CF
1 : city with the key : city
2 : state with the key : state
3 : zipcode with the key : zip

]]>