Skip to content

Instantly share code, notes, and snippets.

@unaibamir
Created September 26, 2018 07:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unaibamir/82a98af3910667ba4fc833d965f0ec4d to your computer and use it in GitHub Desktop.
Save unaibamir/82a98af3910667ba4fc833d965f0ec4d to your computer and use it in GitHub Desktop.
<?php
$args = [
"s" => "logo",
"post_type" => "product",
"posts_per_page" => 5,
"post_status" => "publish"
];
$the_query = new WP_Query( $args );
if( $the_query->found_posts > 0 ) {
/*echo "<pre>";
print_r($the_query->posts);
echo "</pre>";*/
echo "<ul>";
foreach ($the_query->posts as $product) {
$product_id = $product->ID;
echo "<li>";
echo $product->post_title;
echo get_the_post_thumbnail( $product, 'thumbnail', ["class"=>"img-responive", "data-adnan" => "Khan"] );
echo "</li>";
}
echo "</ul>";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment