Support

Account

Home Forums ACF PRO Dúvida com Relação e Repetição dentro da Categoria

Unread

Dúvida com Relação e Repetição dentro da Categoria

  • Olá, já tenho uma relação em uma categoria… Mas, gostaria de adicionar outra relação porém dentro o repetidor dentro dela.

    Meu código atual consiste em verificar se existe um subtopico e se não tiver ele irá exibir os posts que foram atrelados na relação.

    Desejo continuar com essa regra e adicionar um regra que eu também possa adicionar uma nova relação porém que contenha repetição.

    Por favor olhem meu código. Como eu insiro um novo campo de repetidor e dentro dele ter uma relação e depois exibir no front end?

    <?php
    $ts = get_terms( array(

    ‘taxonomy’ => ‘destinos’,

    ‘child_of’ => $term->term_id,

    ‘parent’ => $term->term_id,

    ‘meta_key’ => ‘peso_destinos’,

    ‘orderby’ => ‘meta_value’,

    ‘order’ => ‘DESC’

    ) );

    if ( count($ts) > 0 ) {

    foreach ( $ts as $t ) :

    ?>
    <li class=”category-item col link-seo”>
    <div class=”col category-image”>
    ” alt=”viagem-para-paris-destaque”>
    </div>
    <div class=”col”>
    slug ?>” title=”<?= $t->name ?>”>
    <h2 class=”sub-title upper-all text-bold”><?= $t->name ?></h2>

    <?php if ( get_field(‘preco_destinos’, $t) ) : ?>
    <div class=”price-pac”>
    <span class=”price-start”>A partir de:</span>
    <span class=”price-value”><span class=”text-bold open-font”><?= get_field(‘preco_destinos’, $t) ?></span><?php endif; ?>
    <span class=”price-start”><?= get_field(‘selecao_por_tipo’, $t) ?>
    </span>
    </div>

    </div>

    <?php endforeach; } else { ?>
    <?php
    // WP_Query arguments

    $args = array(

    ‘post_type’ => array( ‘pacotes’ ),

    ‘post_per_page’ => -1,

    ‘term’ => $term->slug,

    ‘taxonomy’ => ‘destinos’,

    ‘meta_key’ => ‘peso_pacotes’,

    ‘orderby’ => ‘meta_value’,

    ‘order’ => ‘DESC’

    );

    // The Query

    $query = new WP_Query( $args );

    // The Loop

    if ( $query->have_posts() and !get_field(‘ordem_pacote’, $term) ) {

    while ( $query->have_posts() ) {

    $query->the_post();

    ?>
    <li class=”category-item col link-seo”>
    <div class=”col category-image”>
    <?php $imagem = get_field(‘imagem_destaque_pacotes’); ?>
    <?php $imagem_other = get_field(‘imagem’); ?>
    <?php $cat_img = catch_that_image(); ?>
    <?php if ( $imagem ) : ?>
    ” alt=”<?= $imagem[‘title’] ?>”>
    <?php elseif ( !empty($cat_img) ) : ?>
    ” alt=”<?= the_title() ?>”>
    <?php elseif ( $imagem_other ) : ?>
    ” alt=”<?= $imagem_other[‘title’] ?>”>
    <?php else: ?>
    “>
    <?php endif; ?>
    </div>
    <div class=”col”>
    ” title=”<?php the_title(); ?>”>
    <h2 class=”sub-title text-bold”><?= the_title(); ?>

    </h2> <p class=”sub-title text-bold”> <?= get_field (‘subtitulo’) ?></p>


    <div class=”roteiro-pac”>
    <span><?= get_field(‘roteiro_texto_pacotes’) ?></span>
    </div>
    <div class=”durac-pac”>
    <span><?= get_field(‘duracao_pacotes’) ?></span>
    </div>
    <div class=”price-pac”>
    <span class=”price-start”><?php the_field(‘selecao_de_parcelamento’); ?></span>
    <?php
    $valor = get_field(‘a_partir_de_pacotes’);

    $local = get_the_terms( get_the_ID(), ‘localizacao’ );

    if ( $local[0]->name == ‘Internacional’ ) {

    $moeda = “US$”;

    $valor_final = moeda(‘dolar’, $valor);

    } else {

    $moeda = “R$”;

    $valor_final = moeda(‘real’, $valor);
    }

    ?>
    <span class=”price-value”><span class=”text-bold open-font”><?= $moeda ?> <?= $valor_final ?></span></span>
    <span class=”price-start”><?php the_field(‘valor_referente’); ?></span>
    </div>
    </div>

    <?php
    }
    } else {
    ?>
    <?php
    //AYRES

    $posts = get_field(‘ordem_pacote’, $term);

    ?>
    <ul class=”category-items-list flex-start flex-wrap”>
    <?php foreach( $posts as $post): // variable must be called $post (IMPORTANT) ?>
    <?php setup_postdata($post); ?>
    <li class=”category-item col link-seo”>
    <div class=”col category-image”>
    <?php $imagem = get_field(‘imagem_destaque_pacotes’); ?>
    <?php $imagem_other = get_field(‘imagem’); ?>
    <?php $cat_img = catch_that_image(); ?>
    <?php if ( $imagem ) : ?>
    ” alt=”<?= $imagem[‘title’] ?>”>
    <?php elseif ( !empty($cat_img) ) : ?>
    ” alt=”<?= the_title() ?>”>
    <?php elseif ( $imagem_other ) : ?>
    ” alt=”<?= $imagem_other[‘title’] ?>”>
    <?php else: ?>
    “>
    <?php endif; ?>
    </div>
    <div class=”col”>
    ” title=”<?= the_title(); ?>”>
    <h2 class=”sub-title text-bold”><?= the_title(); ?>
    </h2>
    <p class=”sub-title text-bold”><?= get_field (‘subtitulo’) ?></p>

    <div class=”roteiro-pac”>
    <span><?= get_field(‘roteiro_texto_pacotes’) ?></span>
    </div>
    <div class=”durac-pac”>
    <span><?= get_field(‘duracao_pacotes’) ?></span>
    </div>
    <div class=”price-pac”>
    <?php
    $valor = get_field(‘a_partir_de_pacotes’);
    $local = get_the_terms(get_the_ID() , ‘localizacao’);

    if ($local[0]->name == ‘Internacional’)
    {
    $moeda = “US$”;
    $valor_final = moeda(‘dolar’, $valor);
    }
    else
    {
    $moeda = “R$”;
    $valor_final = moeda(‘real’, $valor);
    }

    ?>
    <span class=”price-start”><?php the_field(‘selecao_de_parcelamento’); ?></span>
    <span class=”price-value”><span class=”text-bold open-font”><?=$moeda ?> <?=$valor_final ?></span></span>
    <span class=”price-start”><?php the_field(‘valor_referente’); ?></span>
    </div>
    </div>

    <?php endforeach; ?>

    <?php wp_reset_postdata(); // IMPORTANT – reset the $post object so the rest of the page works correctly ?>
    <?php
    }

    // Restore original Post Data

    wp_reset_postdata();

    ?>
    <?php } ?>

Viewing 1 post (of 1 total)

The topic ‘Dúvida com Relação e Repetição dentro da Categoria’ is closed to new replies.