Created
June 30, 2025 15:55
-
-
Save propertyhive/badc60cbd96e1d9c181b7b0ad0964f5b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'elementor/frontend/widget/before_render', function( $widget ) | |
{ | |
// Only target specific widget types if needed | |
if ( $widget->get_name() !== 'property-availability' ) { | |
return; | |
} | |
// Get current post ID | |
$post_id = get_the_ID(); | |
// Get custom taxonomy term | |
$terms = get_the_terms( $post_id, 'availability' ); | |
if ( is_wp_error( $terms ) || empty( $terms ) ) { | |
return; | |
} | |
// Get first term slug or name | |
$term_slug = sanitize_title( $terms[0]->name ); | |
// Add attribute to the widget wrapper | |
$widget->add_render_attribute( '_wrapper', 'data-availability', $term_slug ); | |
}, 10 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment