Hi, ?> <h2 class="email-upsell-title"><?php esc_html_e( 'Tracking information:', 'woo-orders-tracking' ) ?></h2> <?php $text = ''; foreach ( $tracking_info as $item ) { $text .= ', <a href="' . $item['tracking_url'] . '" target="_blank">' . $item['tracking_code'] . '</a>' . esc_html__( ' by ', 'woo-orders-tracking' ) . $item['carrier_name']; } $text = trim( $text, ',' ); echo '<p>' . esc_html__( 'Your tracking number: ', 'woo-orders-tracking' ) . $text . '</p>'; $html = ob_get_clean(); echo ent2ncr( $html ); PHP: Currently, the above code displays the notification in emails like this: - Tracking Information: Your tracking number: HY2587349PO by DHL - I want to display it like this by removing the space line: - Tracking information: Your tracking number: HY2587349PO by DHL - How can I change the code to remove this space between the two lines? Thank you,
You can then add style="" next to your class, like so: <h2 class="email-upsell-title" style="margin-bottom:0; padding-bottom:0"><?php esc_html_e( 'Tracking information:', 'woo-orders-tracking' ) ?></h2> Code (markup): Also, if it still has a space remove the <p></p> and just put a <br> at the end of it: echo '' . esc_html__( 'Your tracking number: ', 'woo-orders-tracking' ) . $text . '<br>'; Code (markup): See if does what you want it to do: ?> <h2 class="email-upsell-title" style="margin-bottom:0; padding-bottom:0"><?php esc_html_e( 'Tracking information:', 'woo-orders-tracking' ) ?></h2> <?php $text = ''; foreach ( $tracking_info as $item ) { $text .= ', <a href="' . $item['tracking_url'] . '" target="_blank">' . $item['tracking_code'] . '</a>' . esc_html__( ' by ', 'woo-orders-tracking' ) . $item['carrier_name']; } $text = trim( $text, ',' ); echo '' . esc_html__( 'Your tracking number: ', 'woo-orders-tracking' ) . $text . '<br>'; $html = ob_get_clean(); echo ent2ncr( $html ); Code (markup):
Thanks, @qwikad.com for your replay, I used style="margin-bottom:0; padding-bottom:0" Code (CSS): , and it works. The spacing is removed. Thank you for your help, Have a great day,
Valid answers from @hdewantara & @qwikad.com. H2 will have a margin-bottom by design, if you don't want that you'll always have to use CSS to change it. Rethink your use of H2.
No, you REALLY don't. And if you do, it would mean you do not have access to where such changes should be made. In the stylesheet. Though really that markup needs to be thrown in the trash. As I'm always saying 90% or more of the time you see style="", you're looking at ignorance, incompetence, or ineptitude since what things look like has NO business in the markup. Much like that code slopping out a stream of anchors with no block level dividers or semantics to explain what they are for, the garbage target attribute being abused to shove new windows down users gullets whether they want it or not, the variables for nothing, output buffering for who knows what likely meaning you can't gzip the result, variables for nothing... Damn that's horrifying.
Guessing WILDLY -- been decades since I dealt with the shitshow that is turdpress, and by extension wooCommerce. <?php echo ' <h2> ', esc_html_e( 'Tracking information:', 'woo-orders-tracking' ), ' </h2> <h3> ', esc_html__( 'Your tracking number(s): ', 'woo-orders-tracking' ), ' </h3> <ul class="trackingNumbers">'; foreach ($tracking_info as $item) echo ' <li> <a href="', $item['tracking_url'], '"> ', $item['tracking_code'], ' </a> ', esc_html__('by ','woo-orders-tracking'), $item['carrier_name'], ' </li>'; } echo ' </ul>'; $html = ob_get_clean(); echo ent2ncr( $html ); Code (markup): Is probably what I'd write there. Anything to do with appearance? That's the stylesheet's job. For example to turn that UL into a comma delimited list... .trackingNumbers li { display:inline; } .trackingNumbers li:not(:first-child):before { content:", "; } Code (markup): Thus you have proper semantics for all users, and your comma delimited result for screen users without a bunch of string manipulation BS games wasting the server's time. I guessed on the heading levels since the second one doesn't seem to be a paragraph, it's a heading for the LIST of numbers that follows. Semantic markup WITHOUT giving a flying purple fish what things look like FIRST. Then you style it FROM YOUR STYLESHEET, not in the bloody markup!