• Resolved vicentefega

    (@vicentefega)


    Hi, im trying to add post custom images in page results apart from post thumbnail. Im using the plugin Advanced Custom Fields, it works adding this code at src:

    src="<?php the_field('name_of_custom_image'); ?>"

    How can I insert this code in your plugin? Im trying this:

    $html .= '<img src="'.the_field(name_of_custom_image).'">';

    but when I inspect the code at page results, the src is empty, and the url of custom image appears written at the beginning of my content div.

    How can I fix it?

    Thank you!

    https://www.ads-software.com/plugins/ajax-wp-query-search-filter/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author TC.K

    (@wp_dummy)

    You will have to put the post id.

    eg.
    the_field('name_of_custom_image', $query->post->ID);

    Thread Starter vicentefega

    (@vicentefega)

    Ups! still not working.. ??

    I have written this:

    $html .= '<section><img src="'.the_field('imagen_de_la_puerta', $query->post->ID).'">';

    Look what happens here here.

    Thank you!

    Plugin Author TC.K

    (@wp_dummy)

    I don’t really know much about ACF, they tend to use their own API to render their field. So it would be better you ask ACF for this support.

    Anyway, you can still try it with get_field() instead.

    Thread Starter vicentefega

    (@vicentefega)

    Perfect!!!!
    It works with get_field()

    This is the code:

    src="'.get_field('name_of_custom_image', $query->postID).'"

    Thank you!!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Add custom image to results’ is closed to new replies.