Fra*_*les 1 php wordpress woocommerce advanced-custom-fields
我在将高级自定义字段集成到 woocommerce 商店页面时遇到了一些困难。\n我的代码是重复器字段,我需要将其添加到商店页面的顶部,但这不起作用。\n我\已经尝试添加页面 ID,但没有任何反应。\n任何帮助或建议将不胜感激。
\n\n我已经在我的子主题中创建了一个 woocommerce 文件夹,并且我正在尝试将此代码添加到 archive-product.php 模板中。
\n\n<div class="container accueil">\n\n <h2 class="titre-section">Tous nos saveurs \xc3\xa0 un seul clic !</h2>\n\n <div class="row products-categories">\n\n <?php if( have_rows(\'categories_menu\') ): ?>\n\n\n\n <?php while( have_rows(\'categories_menu\') ): the_row(); \n\n // vars\n $titre = get_sub_field(\'titre_categorie\');\n $image = get_sub_field(\'image_categorie\');\n ?>\n <a class="link-cat" href="/carte/">\n <div class="col-md-4 product-cat" style="background-image: url(<?php echo $image[\'url\']; ?>);">\n <h2 class="cat-title"><?php echo $titre; ?></h2> \n </div>\n </a>\n <?php endwhile; ?>\n\n <?php endif; ?>\n\n </div>\n </div>\nRun Code Online (Sandbox Code Playgroud)\n\n我没有错误消息。
\n小智 5
您需要获取 Woo-commerce 商店页面 ID,然后将这些 ID 传递给每个 get_field & rows
\n\n<?php if(is_shop()){ ?>\n<div class="container accueil">\n\n <h2 class="titre-section">Tous nos saveurs \xc3\xa0 un seul clic !</h2>\n\n <div class="row products-categories">\n\n <?php $post_id = get_option( \'woocommerce_shop_page_id\' ); ?>\n\n <?php if( have_rows(\'categories_menu\', $post_id) ): ?>\n\n <?php while( have_rows(\'categories_menu\', $post_id) ): the_row(); \n\n $titre = get_sub_field(\'titre_categorie\', $post_id);\n $image = get_sub_field(\'image_categorie\', $post_id);\n ?>\n <a class="link-cat" href="/carte/">\n <div class="col-md-4 product-cat" style="background-image: url(<?php echo $image[\'url\']; ?>);">\n <h2 class="cat-title"><?php echo $titre; ?></h2> \n </div>\n </a>\n <?php endwhile; ?>\n\n <?php endif; ?>\n\n </div>\n </div>\n<?php } ?>\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
4031 次 |
| 最近记录: |