• Resolved patchyart

    (@patchyart)


    Hi,

    I’m trying to display featured products when no products can be found

    Here’s how i’ve tried adding this to the no-products-found.php in a child theme

    <p class="woocommerce-info woocommerce-no-products-found"><?php esc_html_e( 'No products were found matching your selection.', 'woocommerce' ); ?></p>
    <p class="woocommerce-no-products-found-show-featured"><?php esc_html_e( 'Here are some we recommend from our featured sellers:', 'woocommerce' ); ?></p>
    <div>
        <div id="no-products-found-show-featured">
    <p>
    	<?php
    	echo do_shortcode('[products limit="4" columns="2" visibility="featured" ]')
    	?>
    </p>
    </div>

    This causes my page to return a 503 error when loading a no products page, however if i change the shortcode to something else it is successfully displayed??

    Any help appreciated, thanks

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

Viewing 3 replies - 1 through 3 (of 3 total)
  • Saif

    (@babylon1999)

    Hello @patchyart,

    I think it’s just a syntax problem. Try switching to single quotations for the shortcode parameters.

    Like this:

    echo do_shortcode("[products limit='1' columns='1' visibility='featured']");

    Cheers!

    Thread Starter patchyart

    (@patchyart)

    Hi,

    thank you for your reply but this seems to still return the same error

    Here is the code i am using in the no-products-found.php template

    <p class="woocommerce-info woocommerce-no-products-found"><?php esc_html_e( 'No products were found matching your selection, here are some we recommend from our featured sellers:', 'woocommerce' ); ?></p>
    <div>
        <div id="no-products-found">
    <p>
    	<?php
          echo do_shortcode("[products limit='4' columns='4' visibility='featured']");
    	?>
    </p>
    </div>

    Hi @patchyart

    I understand that even after trying Saif’s solution above, the error persists.

    Kindly be informed that custom coding is outside our scope of support, hence, I am leaving this thread open for a bit to see if anyone can chime in to help you out.

    For questions related to development and custom coding, your best bet is to ask on any of these channels for support. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, too.

    Hope this helps!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Putting the [products] in no-products-found.php breaks the page’ is closed to new replies.