PHP Customization - how to display number of properties in Taxonomy (Text Field)?
1 minute read
You can use - https://codex.wordpress.org/Function_Reference/get_term function for this.
We will show how to display number of properties For Sale in the Offer Type as en example on the single property page
-
1
Visit Offer Type page and check a slug of the field (here: offer-type)
-
2
Hover For Sale to see its ID (here:117)
- 3 Now paste this PHP Code at the top of your /wp-content/themes/myhome/templates/single-estate-partials/content-single-estate.php file
<h1>Number of For Sale properties in the Offer Type:
<?php
$term = get_term( 117, 'offer-type' );
echo $term->count;
?>
</h1>
File will look like this:
It will look like this on your single property page. Now you can style it via CSS and change ID (117) or SLUG (offer-type) for any other
Ask the people who build MyHome WPBakery
We answer by email from support@tangiblewp.com. With Premium Support, we also fix your site when something breaks.
We can also run your site for you, or build a new one.
Was this guide helpful?