Home › Forums › General Issues › ajax image
Hi, I need to replace on the code below:
'.get_the_post_thumbnail ().'
by
<?php $image = wp_get_attachment_image_src(get_field('logo'), ''); ?><img />" alt="" />
How to do it? It's not the same language .. ??
function ajax_result($arg, $id,$pagenumber){
$apiclass = new ajaxwpqsfclass();
// The Query
$query = new WP_Query( $arg );
$html ='';
// The Loop
if ( $query->have_posts() ) {
$html .= '<h1>'.__('Search Results :', 'AjWPQSF' ).'</h1>';
while ( $query->have_posts() ) {
$query->the_post();
$html .= '<article><div class="col-md-6" align="center" style="margin:5px;"><a href="'.get_permalink().'" rel=""><div class="col-md-36 col-xs-6" style="margin-right:2px; line-height:0px;"><button style="border-radius: 0px; border:1px dashed #01dacf;width:100%; height:100%; font-size:25px;">'.get_field('valeur_de_la_reduk').' </button></div></a>';
$html .= '<a href="'.get_permalink().'" rel="bookmark"><div class="entry-thumb col-md-36 col-xs-6">'.get_the_post_thumbnail().'</div></a></div>';
$html .= '<div class="col-md-6 col-xs-12" style="margin:5px;"> <header><h1 class="entry-title" style="margin-bottom:5px"><a href="'.get_permalink().'" rel="bookmark">'.get_the_title().'</a></h1></header>';
$html .= '<div style="margin-bottom:5px"><img src="http://www.reduk.net/fr/wp-content/themes/reduk/img/icon_brand.png" alt="" width="35" />'.get_field('nom_de_la_societe_ou_de_la_marque').'</div>';
$html .= '<div style="margin-bottom:5px"><img src="http://www.reduk.net/fr/wp-content/themes/reduk/img/icon_reduk.png" alt="" width="35" />'.get_field('valeur_de_la_reduk').'</div>';
$html .= '<div style="margin-bottom:5px"><img src="http://www.reduk.net/fr/wp-content/themes/reduk/img/icon_city.png" alt="" width="35" />'.get_field('ville').'</div>';
$html .= '<div style="margin-bottom:5px"><img src="http://www.reduk.net/fr/wp-content/themes/reduk/img/icon_expire.png" alt="" width="35" />Expire le: '.do_shortcode('[postexpirator]').'</div></div></article>';
$html .= '<a href="'.get_permalink().'" rel=""><div style="margin:5px;"><button style="width:100%; font-size:25px;">J'en profite</button></div></a>';
$html .= '<hr width="100%">';
}
$html .= $apiclass->ajax_pagination($pagenumber,$query->max_num_pages, 4, $id);
} else {
$html .= __( 'Nothing Found', 'AjWPQSF' );
}
/* Restore original Post Data */
wp_reset_postdata();
return $html;
}
}//end class
Hi @hamraras
Wordpress expects the first parameter in the method to be the attachment id.
https://developer.wordpress.org/reference/functions/wp_get_attachment_image_src/
Have you correctly set the field to return ID
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
🚨 The 2023 ACF Annual Survey closes tomorrow! This is your last chance to complete the survey and help guide the evolution of ACF. https://t.co/0cgr9ZFOJ5
— Advanced Custom Fields (@wp_acf) May 18, 2023
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.