Not working with get_term_by
-
Hi, I setup the plugin re-ordered my subcategories in the dashboard and selected option Custom Order as defined above.
But nothing changes
my code: ` $terms = get_field( ‘travel_categories’ );
if ( $terms ) { ?><div class=”travel_type__cat-details”>
<?php foreach ( $terms as $term ) { ?>
<?php
$term_link = get_term_link( $term );
$travel_category = get_term_by( ‘id’, $term, ‘category’ );
$image = ”;
$image_id = get_term_meta( $travel_category->term_id, ‘image’, true );
$image_data = wp_get_attachment_image_src( $image_id, ‘full’ );
$image = $image_data[0];
?><div class=”col-md-3 col-sm-6 col-xs-12″>
<a href=”<?php echo esc_url( $term_link ); ?>” style=”background-image:url(‘<?php echo esc_url( $image ); ?>’)”>
<h2><?php echo esc_html( $travel_category->name ); ?></h2>
</a>
</div>
<?php } ?></div>
<?php } ?>`
The topic ‘Not working with get_term_by’ is closed to new replies.