Thumbnails Not Generating For Popular Posts Table
-
I was hoping to not bother anyone with this request because I feel like it’s pretty simple but I’ve been at it for a while and I don’t know where to go from here. Hope this is all the code you’d need to help.
<table class="table" > <?php $numPosts = 0; $popularpost = stats_get_csv( 'postviews', array( 'days' => -1, 'limit' => 100 ) ); foreach ($popularpost as $post){ $aux = get_post_meta($post['post_id'], 'wpb_post_views_count', true); $price = get_post_meta($post['post_id'], 'post_price', true); if(!empty($aux) && !empty($price) && $numPosts < 10){ $numPosts++; $author_id = get_post_field( 'post_author' , $post['post_id']); $author_url = get_the_author_meta( 'nicename', $author_id ); $author = get_the_author_meta( 'display_name', $author_id ); $listThumb = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?> <tr> <td><a href="<?php echo $post['post_permalink']; ?>"><img src="<?php echo $listThumb; ?>"</a></td> <td><a href="<?php echo $post['post_permalink']; ?>"><?php echo $post['post_title']; ?></a></td> <td><a href="./author/<?php echo $author_url; ?>"><?php echo $author; ?></a></td> <td><?php echo $price; ?></td> </tr> <?php } } ?> </table>Not sure what I’m doing wrong here. Everything else (post name, author name, etc) generates properly. Any advice would be greatly appreciated or let me know if you need more info. Thanks!
Viewing 1 replies (of 1 total)
-
I know there’s a rule against bumping your own posts but I just wanted to return to say I found the solution. New code posted below:
<table class="table" > <?php $numPosts = 0; $popularpost = stats_get_csv( 'postviews', array( 'days' => -1, 'limit' => 100 ) ); foreach ($popularpost as $post){ $aux = get_post_meta($post['post_id'], 'wpb_post_views_count', true); $price = get_post_meta($post['post_id'], 'post_price', true); if(!empty($aux) && !empty($price) && $numPosts < 10){ $numPosts++; $author_id = get_post_field( 'post_author' , $post['post_id']); $author_url = get_the_author_meta( 'nicename', $author_id ); $author = get_the_author_meta( 'display_name', $author_id ); $listThumb = get_the_post_thumbnail( $post['post_id'] ); ?> <tr> <td><a href="<?php echo $post['post_permalink']; ?>"><?php echo $listThumb; ?></a></td> <td><a href="<?php echo $post['post_permalink']; ?>"><?php echo $post['post_title']; ?></a></td> <td><a href="./author/<?php echo $author_url; ?>"><?php echo $author; ?></a></td> <td><?php echo $price; ?></td> </tr> <?php } } ?> </table>Hope this helps anyone who was also in my position.
Viewing 1 replies (of 1 total)
The topic ‘Thumbnails Not Generating For Popular Posts Table’ is closed to new replies.