gcarrenos
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Hide featured image if there isnt' one<?php $image = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?> if ($image) { ?> <div id="featuredimage" style="background-image: url('<?php echo $image; ?>')"> </div> <?php } ?>[Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]
Try like this! I forgot to close the tag
Forum: Fixing WordPress
In reply to: Hide featured image if there isnt' one<?php
$image = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>
if ($image) {
<div id=”featuredimage” style=”background-image: url(‘<?php echo $image; ?>’)”>
</div>
<?php } ?>Forum: Fixing WordPress
In reply to: how to get woocommerce best selling product via loopThis should make it work, adding this into your args
‘meta_key’ => ‘total_sales’,
‘orderby’ => ‘meta_value_num’,For example:
<?php
$args = array(
‘post_type’ => ‘product’,
‘posts_per_page’ => 4,
‘meta_key’ => ‘total_sales’,
‘orderby’ => ‘meta_value_num’,
);$loop = new WP_Query( $args );
if ( $loop->have_posts() ) {
while ( $loop->have_posts() ) : $loop->the_post();
woocommerce_get_template_part( ‘content’, ‘product’ );
endwhile;
} else {
echo __( ‘No products found’ );
}wp_reset_query();
?>