• Resolved Robin

    (@cinghaman)


    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 } ?>`

Viewing 1 replies (of 1 total)
  • Plugin Author Marcel Pol

    (@mpol)

    What exactly do you expect to see here, and what are you seeing?

    I tested here with a ACF field (I suppose you are using ACF) that has tags inside. The tags just followed the order I set it to.
    Using the line:
    $terms = get_field( ‘travel_categories’ );
    resulted in a terms array that was sorted correctly.

    In your code, the get_term_by will just follow the order in the terms array. It is really ACG get_field where it all happens.

Viewing 1 replies (of 1 total)

The topic ‘Not working with get_term_by’ is closed to new replies.