WooCommerce display price before add to cart [closed]

The variable $product is undefined when your function runs, you need to access the object to call the method get_price_html(). One way to do it is to call the global variable: add_action( ‘woocommerce_before_add_to_cart_button’, ‘misha_before_add_to_cart_btn’ ); function misha_before_add_to_cart_btn(){ global $product; echo ‘<div class=”btn-price”>’.$product->get_price_html().'</div>’; }

Category Page Displaying all Pages

Resolved using this: <div> <ul> <?php $current_category = get_queried_object(); ////getting current category $args = array( ‘post_type’ => ‘page’,// your post type, ‘orderby’ => ‘menu_order’, ‘order’ => ‘DESC’, ‘cat’ => $current_category->cat_ID // current category ID ); $the_query = new WP_Query($args); if($the_query->have_posts()): while($the_query->have_posts()): $the_query->the_post(); echo ‘<h2><a href=”‘.get_the_permalink().'”>’.get_the_title().'</a></h2>’; “<p>”.the_excerpt().”</p>”; endwhile; endif; ?> </ul> </div>

How can I prevent a shortcode div from extending beyond its boundaries?

because I’m not echoing anything in this code. But you are! This code: function smb_function( $atts ) { ?> <div class=”social_button_shortcode”><?php Is the same as: function smb_function( $atts ) { echo ‘ <div class=”social_button_shortcode”>’; Likewise with the closing div tag at the end. Any form of direct output in a shortcode will break it, wether … Read more