On single product page if you select a default category from within product, it only shows this…

This topic has 4 replies, 2 voices, and was last updated 1 months, 4 weeks ago ago by Andrew Mitchell

  • Avatar: Niddy
    Niddy
    Participant
    October 7, 2025 at 10:27

    Hi

    When you select the primary category within single product – in the XStore Options box at the bottom, on the single product page within the meta box it only shows this singular category – even though the product may belong in several categories.

    The default behaviour is when you select a primary category, this is used within the url structure however the breadcrumbs stay intact and dont change between the other categories and also it shows all the categories on the single product page within the meta block that shows sku / category / tags etc.

    This suggests your method is changing the structure slightly – however, my query is specifically:

    How do we set the primary category and still show all categories that product sits in, within the meta block on the single product page please?

    Thanks

    Please, contact administrator
    for this information.
    3 Answers
    Avatar: Andrew Mitchell
    Andrew Mitchell
    Support staff
    October 7, 2025 at 13:49

    Hello, Niddy,

    Could you please provide temporary wp-admin and FTP access? We will check what can be done to help you.
    To grant WP-Admin access, please proceed to create a new user account with an administrator role through your WordPress Dashboard. Once the account is established, you may securely transmit the username and password to us via the Private Content section designated for this purpose.

    For FTP access, we require the following details: FTP host, FTP username, FTP password, FTP port, and FTP encryption type. If you need assistance in creating these credentials, please reach out to your hosting provider who will guide you through the process.

    Best Regards,
    8Theme’s Team

    Avatar: Niddy
    Niddy
    Participant
    October 7, 2025 at 14:39

    Hiya

    I ended up writing a snippet to do this for me using shortcode – details below for ease; maybe look to implement it as default as really, all categories should be visible within Meta.

    Thanks again

    Add this to child theme functions.php

    // ==================================================================
    // Display Product Categories with Singular/Plural Label
    // ==================================================================
    
    function custom_product_categories_list() {
        global $product;
    
        // Ensure we’re on a product page
        if ( ! is_product() || ! $product ) {
            return '';
        }
    
        // Get product categories
        $categories = wp_get_post_terms( $product->get_id(), 'product_cat' );
    
        if ( empty( $categories ) ) {
            return '';
        }
    
        // Build category links
        $category_links = array();
        foreach ( $categories as $category ) {
            $link = get_term_link( $category );
            if ( ! is_wp_error( $link ) ) {
                $category_links[] = '<a href="' . esc_url( $link ) . '">' . esc_html( $category->name ) . '</a>';
            }
        }
    
        // Determine label
        $label = count( $category_links ) > 1 ? 'Categories' : 'Category';
    
        // Output HTML
        $output  = '<div class="custom-product-categories">';
        $output .= '<strong>' . esc_html( $label ) . ':</strong> ';
        $output .= implode( ', ', $category_links );
        $output .= '</div>';
    
        return $output;
    }
    
    // === Shortcode to use in Elementor or Gutenberg ===
    add_shortcode( 'product_categories_list', 'custom_product_categories_list' );

    Then in elementor page builder, add this shortcode where you want them rendered (ie above meta block) – [product_categories_list]

    Then it does what we need. At least I think it does. Just testing now.

    Thanks 🙂

    Avatar: Andrew Mitchell
    Andrew Mitchell
    Support staff
    October 8, 2025 at 08:20

    Hello Niddy,

    Thank you for providing the snippet. Unfortunately, we are unable to implement it by default, as our primary category system is designed to display only those categories. Adding this snippet could affect the experience for other users. However, we will keep it and recommend it if someone else wishes to modify the appearance of the primary categories in a similar way.

    Thank you for your understanding.

    Best regards,
    8Theme Team

  • Viewing 4 results - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.Log in/Sign up

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.