Einzelner Standortname abrufen

User
$termstandort = wp_get_post_terms(get_the_ID(), 'standort');
get only single name
Assistant
You can extract a single name from the taxonomy term using this approach:

$termstandort = wp_get_post_terms(get_the_ID(), 'standort');
if (!empty($termstandort) && !is_wp_error($termstandort)) {
    echo esc_html($termstandort[0]->name); // Outputs the first term name
}

This ensures that:
1. `wp_get_post_terms()` returns terms without errors.
2. The first term (`$termstandort[0]`) exists before accessing its `name` property.

Let me know if you need modifications! ๐Ÿš€

Leave a Comment

Your email address will not be published. Required fields are marked *