Support

Account

Home Forums Bug Reports ACF block does not work with wc_get_template_part

Solving

ACF block does not work with wc_get_template_part

  • Hello,

    I created a block to display WooCommerce product list and I loaded the product template file with wc_get_template_part().

    It was working fine, but after updating ACF Pro to version 5.11, the block stops showing the product list in editor (on front-end it works fine). In editor the block is empty.

    When I downgrade ACF Pro to 5.10.2, it works fine again.

    Can someone help me?

  • Hey @kezily

    Could you drop us an email to support@advancedcustomfields.com with a copy of your block registration and template code so we can try to reproduce this?

    Thanks!

  • Hi @lgladdy,

    I sent an email to support.

    Thank you.

  • What if you try:
    <?php include( locate_template( 'includes/loop.php', false, false ) ); ?>

    Just change the directory from includes to what you need and loop.php to the name of your file.

    Does that work for you?

  • How did this turn out? I wish it had been public so I could see, because I’ve experienced the same thing with wc_get_template_part()– it renders an empty block, but if you switch to Preview mode and back to Edit, the block renders fine. It works fine on the front end, of course. If I just individually call for the_title, the_content, the_post_thumbnail, for example, it works perfectly on the back end, but I obviously want all the woocommerce goodies like price etc.

    It’s been this way for quite a while but it’s not a showstopper since you can toggle preview/edit.

  • Hello @girldetective

    Unfortunately it was not resolved by ACF support. I still have the same problem.

    Support reported that this issue is from WooCommerce and not ACF.

  • Thanks for letting me know!

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

You must be logged in to reply to this topic.