Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter onico0

    (@onico0)

    Sorry, what an easy (typical to WordPress) issue ^_^ (my bad).

    Here the code, simply use get_terms.

    (with foreach)

    <!-- Location -->
    <div class="property-location">
        <?php 
    
        $property_locations = get_terms('location'); 
    
        if ( ! empty( $property_locations ) && ! is_wp_error( $property_locations ) ) {
            $count = count( $property_locations );
            $i = 0;
            $term_list = '<p class="property-location">';
            foreach ( $property_locations as $property_location ) {
                $i++;
                $term_list .= '<a href="' . esc_url( get_term_link( $property_location ) ) . '">' . $property_location->name . '</a>';
                if ( $count != $i ) {
                    $term_list .= ' &middot; ';
                }
                else {
                    $term_list .= '</p>';
                }
            }
            echo $term_list;
        }
    
        ?>
    </div>
    Thread Starter onico0

    (@onico0)

    Sorry I made a mistake ! Use wp_get_post_terms instead of get_terms (will not works coz retreive all terms !).

    $property_locations = wp_get_post_terms(get_the_ID(), 'location');

    Kiss.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to link to location / suburb (taxonomy) in listing and property details ?’ is closed to new replies.