Home Forums WoodMart support forum How to put in certain content for a category as a whole

How to put in certain content for a category as a whole

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #652017

    hey3212
    Participant

    Hi,

    I want to display ”Upcoming Soon'” for the category Bracelets as a whole when a user hit that section from the home page. How to do this?

    Attachments:
    You must be logged in to view attached files.
    #652080

    Hello,

    It looks like you’re aiming to display a custom message like “Upcoming Soon” when there are no products assigned to a category, and the default WooCommerce message is “No products were found matching your selection.”

    To display the “Upcoming Soon” message for all product categories when there are no products in the category, you can modify the code to work for all categories. Try to add the following code in function.php of the theme.

    // Display "Upcoming Soon" message for all product categories when no products are found
    function display_upcoming_soon_message_for_empty_categories() {
        if ( is_product_category() && ! have_posts() ) {
            // Remove the default WooCommerce message
            remove_action( 'woocommerce_no_products_found', 'wc_no_products_found', 10 );
            
            // Display custom "Upcoming Soon" message
            echo '<h2 class="upcoming-soon-message" style="text-align: center; color: #FF6347; font-size: 24px; font-weight: bold;">Upcoming Soon</h2>';
        }
    }
    add_action( 'woocommerce_archive_description', 'display_upcoming_soon_message_for_empty_categories', 20 );

    You can also enable Maintenance Mode in WooCommerce by navigating to the Settings section and adjusting the site visibility.

    Navigate to > WooCommerce Settings > Site visibility and choose the coming soon: https://ibb.co/xK4WvNDJ

    Best Regards,

    #652087

    hey3212
    Participant

    Hi,

    Thanks for your reply. You said ”Try to add the following code in function.php of the theme.” Where to find the “function.php of the theme”? How to navigate to this location to add the code?

    #652139

    Hello,

    Navigate to Appearance > Theme File Editor > On the right side, you’ll see a list of theme files. Look for:

    Theme Functions (functions.php)

    Click on functions.php to open it.

    Scroll to the bottom and paste the code you received.

    Click the Update File button to save changes.

    See the Screenshot for a better understanding: https://ibb.co/zV3Hyyjy

    Best Regards,

    #652145

    hey3212
    Participant

    Awesome. This has solved my problem. Thanks a lot!

Viewing 5 posts - 1 through 5 (of 5 total)