use php in shortcode

Question

hi
i make a shortcode and is working very good
but my problem is i can just use

function short1( $atts , $content = null ) {
return ”.$content.”;
}
add_shortcode( ‘shor1’, ‘short1’ );

how can i add php to shorcode replace with div class red

is my false way!!!

function short1( $atts , $content = null ) {
return ‘ ‘product’,’posts_per_page’=>’6′ ) ); ?>
have_posts() ) : ?>
have_posts() ) : $the_query->the_post(); ?>

“>
“>

get_price_html(); ?>

add_to_cart_url(); ?>” class=”add-to-cart”>

‘.$content.”;
}
add_shortcode( ‘shor1’, ‘short1’ );

0
, Farhad Sarboalndi 3 years 2020-06-07T06:10:32-05:00 0 Answers 87 views 0

Leave an answer

Browse
Browse