Forums Forums Search & Filter Pro Variable in results.php

Viewing 10 posts - 1 through 10 (of 16 total)
  • Anonymous
    #199075

    Hi there. I´m getting well a variable ($textobt) in results.php loop, but when I apply a filter or I when I get more results when scroll the page, I can’t ge the variable.

    This is my code

    	<div class="search-filter-results-list">
    		<div class="row">
    			<?php $textobt = get_field('texto_boton'); ?>
    			<?php  
    				while ($query->have_posts())
    				{
    					$query->the_post();
    					
    					?>
    
    					<article class="search-filter-result-item col-xs-6 col-sm-3 col-lg-2 item-n">
    				        <div class="item-espectaculo">
    				          <?php the_post_thumbnail('thumbnail', array('class' => 'item-img'), [ 'alt' => esc_html ( get_the_title() ) ]);?>
    				          <div class="item-container">
    				            <div class="ciudad"><img />/images/icon-position.png" height="13" class="icon-pos"><?php the_field('ciudad'); ?></div>
    				            <h1><?php the_title(); ?></h1>
    				            <div class="item-fechas"><?php the_field('desde'); ?> - <?php the_field('hasta'); ?></div>
    				            <div class="sep-info"></div>
    				            <!-- <div class="item-preciodesde">Desde <span class="carga-precio">0</span>€</div> -->
    				            <button type="submit" onclick="window.location.href = '<?php the_field('url_espectaculo'); ?>';" class="btn btn-primary btn-lg btn-block bt-item"><?php echo $textobt; ?></button>
    				          </div>
    				        </div>
    				    </article>
    					
    					<?php
    				}
    			?>
    		</div>
    	</div>

    And this is my site: https://eventos.entradas.com/

    Thanks.

    Trevor
    #199084

    Try moving this line:

    <?php $textobt = get_field('texto_boton'); ?>
    

    To immediately after this line:

    $query->the_post();
    
    Anonymous
    #201530

    Hi Trevor, sorry for the delay.
    That solution it’s worst, if I do that the variable doesn’t get nothing, even the the 8 first results.

    Any other solution?

    Trevor
    #201589

    Maybe my code and suggestion was almost corect, but it needs the post ID, like this:

    <?php $textobt = get_field('texto_boton', get_the_ID() ); ?>

    Anonymous
    #202311

    neither!

    Trevor
    #202361

    Is the field texto_boton on each of the results, or on something else?

    Anonymous
    #205561

    Hi Trevor, “texto_boton” field it’s out of each result. It´s in the page that contains de results, via Advance Custom Fields plugin.

    Trevor
    #205593
    This reply has been marked as private.
    Anonymous
    #206261
    This reply has been marked as private.
    Trevor
    #206279

    I understand what you are doing now, and what is wrong. I have changed the code in your results file. For now I have commented out sections of your code, on lines 33 and 50 and added fetching the ACF value in line 50, with the addition of the page ID for the home page in the argument.

Viewing 10 posts - 1 through 10 (of 16 total)