Advertisement
nshelper

Untitled

Sep 24th, 2024
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.03 KB | None | 0 0
  1.             global $post;
  2.            
  3.             while ( $results->have_posts() ) {
  4.                 $results->the_post();
  5.                
  6.                 if ( isset ( $post->blog_id ) )
  7.                     switch_to_blog( $post->blog_id );
  8.  
  9.                 if ( $post_type == 'product' && woodmart_woocommerce_installed() ) {
  10.                     $product = $factory->get_product( get_the_ID() );
  11.  
  12.                     $suggestions[] = array(
  13.                         'value' => html_entity_decode( get_the_title() ),
  14.                         'permalink' => get_the_permalink(),
  15.                         'price' => $product->get_price_html(),
  16.                         'thumbnail' => $product->get_image(),
  17.                         'sku' => $product->get_sku() ? esc_html__( 'SKU:', 'woodmart' ) . ' ' . $product->get_sku() : '',
  18.                     );
  19.                 } else {
  20.                     $suggestions[] = array(
  21.                         'value' => html_entity_decode( get_the_title() ),
  22.                         'permalink' => get_the_permalink(),
  23.                         'thumbnail' => get_the_post_thumbnail( null, 'medium', '' ),
  24.                     );
  25.                 }
  26.                
  27.                 if ( isset ( $post->blog_id ) )
  28.                     restore_current_blog( $post->blog_id );
  29.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement