Support

Account

Home Forums ACF PRO ACF is not working correctly on my search.php

Solved

ACF is not working correctly on my search.php

  • Hello good morning, I need your help;
    (I am not an expert using wordpress)

    My problem is the next:

    I have a search.php file, but just in this file the ACF plugin does not work fine.

    Issue #1 – Images

    If I have saved an image with an image field ACF is just giving me the ID, I need the url or the array ($image[‘url’]). (I am using the array or url configuration)

    To get the url I need to do this:

    $image = get_field('image', 'option');

    To show the url is like this:

    <img src="<?php echo $image['url']; ?>">

    or just:

    <img src="<?php echo $image; ?>">

    ACF is not getting me the url, this is showing just the id

    To fix this I am using this code

    $id = wp_get_attachment_image_src( get_field('image', 'option'), 'auto' );
    
    $url = $id[0];

    <img src="<?php echo $url; ?>">

    I think this is not the best solution, I need to know what is happening, why my ACF is not working fine just in this file.

    Issue #2

    The repeater is not working just on this file.

    if( have_rows('search_sponsors_partners', 'option') ):
    
    					// loop through the rows of data
    					  while ( have_rows('search_sponsors_partners', 'option') ) : the_row();
    
    					      // display a sub field value
    					      $url = the_sub_field('search_sponsors_partners_url', 'option');
    
    					      echo $url;
    
    					  endwhile;
    
    					else :
    
    					  // no rows found
    
    					endif;

    I really need your help to fix this, sorry for my English.

  • Hey these issues was generated by my filters on my functions.php file. I have deleted my filters to add more functionality on my search input and I have added the plugin “Search Everything”.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.