Support

Account

Home Forums General Issues ajax image

Solving

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&apos;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

  • This is exactly what I am looking for.

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

The topic ‘ajax image’ is closed to new replies.