I try to print a link in tag or , the link is needed inside the element, and looking at the code it should be executed and be there, but it appears after the tags, outside of them, outside.
$args = array(
'post_type' => 'product',
'posts_per_page' => 10,
'product_cat' => 'vodostoykiy',
'post_status' => 'publish',
);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) :
$loop->the_post();
global $product;
$bColor = get_post_meta( $loop->post->ID, 'background_color', true );
$img = '<div class="col-sm-6 card-img-top">' . woocommerce_get_product_thumbnail() . '</div>';
$title = '<h2>' . $loop->post->post_title . '</h2>';
$escription = '<div class="card-body">' . $loop->post->post_excerpt . '</div>';
$cardBody = '<div class="col-sm-6 card-block-text">' . $title . $escription . '</div>';
$card = '<div class="row my-card bcolor ' . $bColor . ' ">' . $img . $cardBody . '</div>';
echo '<div><a href="' . get_permalink() . '">' . $card . woocommerce_template_loop_add_to_cart( $args = array() ) . '</a></div>';
endwhile;
wp_reset_query();
Pay attention to the function, it should create a link inside the tags, but somehow the link is outside the tags.
woocommerce_template_loop_add_to_cart( $args = array() )
Update:
I found the problem. What filter does not allow you to attach tag to tag. Ostalso understand what and why)
Bed step:
echo '<div><a href="' . get_permalink() . '">' . $card . com_b4_woocommerce_template_loop_add_to_cart(). '</a>' . '</div>';
Goof step:
echo '<div><a href="' . get_permalink() . '">' . $card . '</a>' . com_b4_woocommerce_template_loop_add_to_cart() . '</div>';
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…