Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <ul class="product-menu">
- <?php
- $products = new WP_Query(
- $args = array(
- 'post_type' => 'product',
- 'post_status' => 'publish',
- )
- );
- while ( $products->have_posts() ) {
- $products->the_post();
- $post_thumbnail_id = get_post_thumbnail_id();
- $post_thumbnail_url = wp_get_attachment_url( $post_thumbnail_id );
- echo
- '<li>
- <a href="' . the_permalink() . '">
- <img src="' . $post_thumbnail_url . '" alt="' . get_the_title() . '">
- </a>
- </li>';
- }
- /* Restore original Post Data */
- wp_reset_postdata();?>
- </ul>
- <ul class="product-menu">
- <?php
- $args = array(
- 'post_type' => 'product',
- 'post_status' => 'publish',
- )
- $products = new WP_Query($args);
- while ( $products->have_posts() ) {
- $products->the_post();
- echo '<li><a href="' . get_the_permalink() . '">';
- // check if the post has a Post Thumbnail assigned to it.
- if ( has_post_thumbnail() ) {
- the_post_thumbnail();
- }
- echo '</a></li>';
- }
- /* Restore original Post Data */
- wp_reset_postdata();
- ?>
- </ul>
Add Comment
Please, Sign In to add comment