• Resolved ohmykomu

    (@ohmykomu)


    I have added product attributes to the shop page with the code below but I need to change the spacing, Ideally I need less room above and below the attribute, please see screenshot https://snipboard.io/GYSi0c.jpg

    add_action('woocommerce_after_shop_loop_item_title', 'display_custom_product_attributes_on_loop', 5 );
    function display_custom_product_attributes_on_loop() {
    global $product;

    // Settings: Here below set your product attribute label names
    $attributes_names = array('Från');

    $attributes_data = array(); // Initializing

    // Loop through product attribute settings array
    foreach ( $attributes_names as $attribute_name ) {
    if ( $value = $product->get_attribute($attribute_name) ) {
    $attributes_data[] = $value;
    }
    }

    if ( ! empty($attributes_data) ) {
    echo '<div class="items" style="color: black; font-size: 12px;"><p>' . implode( '<br>', $attributes_data ) . '</p></div>';
    }
    }

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Support shahzeen(woo-hc)

    (@shahzeenfarooq)

    Hi there!

    The space is caused by the default margin-bottom applied to the <p> tag. To remove this space, you’ll need to set the margin-bottom to 0px in the code where the <p> tag is being added.

    Alternatively, you can use the following custom CSS code:

    .woocommerce-shop  .items p{
    margin-bottom: 0px !important;
    }

    I hope this helps. Please note that, generally, we do not provide support for customizations. If you need more in-depth support or want to consider professional assistance for customization, I can recommend WooExperts and Codeable.io as options for getting professional help. Alternatively, you can also ask your development questions in the  WooCommerce Community Slack as custom code falls outside our usual scope of support.

Viewing 1 replies (of 1 total)

The topic ‘shop page code question’ is closed to new replies.