Meta box Group with tags showing up twice in output
- This topic has 3 replies, 1 voice, and was last updated 2 years, 7 months ago by
Denise Field.
Viewing 4 posts - 1 through 4 (of 4 total)
-
AuthorPosts
-
September 26, 2022 at 1:29 AM #38414
Denise Field
ParticipantHi
I am creating a custom product page on Woocommerce Products. In that layout I have a Metabox that adds bullet points, each bullet point is wrapped in
<li></li>
tags, set up in the advanced tab on the field creation.But the output is showing twice, the first one has been duplicated by woocommerce, but its definitely not my code as I gave the
<UL>
tag a class and the first one has none.Any Ideas
Here is the code I added to the woocommerce short description file
if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } global $post; $short_description = apply_filters( 'woocommerce_short_description', $post->post_excerpt ); if ( ! $short_description ) return; // Bullet Points $bullet_points = '<ul class="product__short-description--bullets">' . rwmb_the_value( "product_bullet_point" ) . '</ul>'; // The custom text $custom_text = '<ul class="product__short-description--bullets--red"> <li>Please see our <a href="https://www.pinkequine.com/buyers-guide/">Buyers Guide</a> for current delivery times on Bespoke Products</li> </ul>'; ?> <div class="product__short-description"> <?php echo $short_description . $bullet_points . $custom_text ; // WPCS: XSS ok. ?> </div>
Here is the output screenshot
Here is the HTML source screenshot
September 26, 2022 at 1:37 AM #38415Denise Field
ParticipantSorry am having trouble getting the images to show up
Here is the Browser OutputSeptember 26, 2022 at 1:38 AM #38416Denise Field
Participantif ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } global $post; $short_description = apply_filters( 'woocommerce_short_description', $post->post_excerpt ); if ( ! $short_description ) return; // Bullet Points $bullet_points = '<ul class="product__short-description--bullets">' . rwmb_the_value( "product_bullet_point" ) . '</ul>'; // The custom text $custom_text = '<ul class="product__short-description--bullets--red"> <li>Please see our <a href="https://www.pinkequine.com/buyers-guide/">Buyers Guide</a> for current delivery times on Bespoke Products</li> </ul>'; ?> <div class="product__short-description"> <?php echo $short_description . $bullet_points . $custom_text ; // WPCS: XSS ok. ?> </div>
September 26, 2022 at 3:27 AM #38417Denise Field
ParticipantOk I solved it myself, I was using the wrong code snippet
I used this and it worked
<?php $values = rwmb_meta( 'my_field_id' ); ?> <ul> <?php foreach ( $values as $value ) : ?> <li><?= $value ?></li> <?php endforeach ?> </ul>
-
AuthorPosts
Viewing 4 posts - 1 through 4 (of 4 total)
- You must be logged in to reply to this topic.