标签: advanced-custom-fields

ACF Gutenberg 块未在后端渲染光滑滑块

我已经设置了 ACF Gutenberg Block 以在后端编辑器中渲染光滑的滑块,并且我放置了一个 console.log 以确保查看它是否加载,并且确实加载了。但是,它不会像前端那样渲染滑块。

我尝试过同时使用这两种enqueue_block_assets方法,enqueue_block_editor_assets但这些都不起作用。

我的 JavaScript 排队:

    wp_enqueue_script(
        'slick',
        plugins_url('slick.js', __FILE__),
        ['wp-blocks', 'wp-element', 'wp-components', 'wp-i18n'],
        filemtime(plugin_dir_path(__FILE__) . 'slick.js')
    );

    wp_enqueue_script(
        'slick-init',
        plugins_url('init-slick.js', __FILE__),
        ['wp-blocks', 'wp-element', 'wp-components', 'wp-i18n'],
        filemtime(plugin_dir_path(__FILE__) . 'init-slick.js')
    );
Run Code Online (Sandbox Code Playgroud)

我的 CSS 排队:

wp_enqueue_style(
   'slick-css',
   plugins_url( '/resources/slick.css', __FILE__),
   [  'wp-blocks', 'wp-element', 'wp-components', 'wp-i18n' ],
   filemtime( plugin_dir_path( __FILE__ ) . '/resources/slick.css')
);

wp_enqueue_style(
   'slick-theme-css',
   plugins_url( '/resources/slick-theme.css' __FILE__),
   [  'wp-blocks', 'wp-element', 'wp-components', 'wp-i18n' ],
   filemtime( plugin_dir_path( __FILE__ ) . '/resources/slick-theme.css')
);
Run Code Online (Sandbox Code Playgroud)

我的 Init-slick.js …

javascript php wordpress advanced-custom-fields wordpress-gutenberg

1
推荐指数
1
解决办法
2959
查看次数

如何使用 acf 将自定义字段添加到 woocommerce 商店页面

我在将高级自定义字段集成到 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>\n
Run Code Online (Sandbox Code Playgroud)\n\n

我没有错误消息。

\n

php wordpress woocommerce advanced-custom-fields

1
推荐指数
1
解决办法
4031
查看次数

使用 ACF 字段中的内容动态填充联系表单 7 下拉字段

我一直在使用旧的 Wordpress 联系表单插件 (FastSecureContactForm) 以及几年前有人为我构建的一些 javescript,以使用从 ACF 字段中提取的文件标题下拉列表动态填充表单中的字段。这对我来说非常有效,但我已经重建了我的网站,现在正在使用联系表 7 并希望重复此功能。

之前使用的 Javascript 引用了 ACF 字段,从中获取(多个)轨道名称,track_name并引用 FastSecureContactForm 中的表单字段,其中文件名列表将动态构建为si_contact_ex_field2_3数字 2 在设置和数字中引用表单 2 的位置3 引用了ex_field3表单上的额外字段 3 ( )。与此功能相关的javascript部分如下(我了解基本的php,但没有javascript知识):

    <script type="text/javascript">

var field_to_update = document.getElementById('si_contact_ex_field2_3');
field_to_update.innerHTML = '';

var elOptNew = document.createElement('option');
elOptNew.text = 'Select'
elOptNew.value = 'Select';

field_to_update.add(elOptNew);

field_to_update.options[0].selected = true;

var track_names = document.getElementsByName('audioFileName');  

for (i=0; i<track_names.length; i++) {

    var track_name = track_names[i].innerHTML;

    var elOptNew = document.createElement('option');
    elOptNew.text = track_name.replace("&amp;", "&");
    elOptNew.value = track_name;

    field_to_update.add(elOptNew); // …
Run Code Online (Sandbox Code Playgroud)

javascript contact-form-7 advanced-custom-fields

1
推荐指数
1
解决办法
6726
查看次数

分类(类别)中的 ACF 中继器不起作用

在分类类别中,我有:

中继器字段命名为问题。在中继器内,我有一个名为answer的字段。

我试图在category.php 文件中显示所有答案,如下所示:

$term = get_queried_object();

if ( have_rows( 'questions',   $term ) ) {
    while( have_rows( 'questions',   $term ) ) {
        the_row();
        the_sub_field( 'answer' );
    }
}
Run Code Online (Sandbox Code Playgroud)

这不起作用。你能告诉我这里出了什么问题吗?我已经尝试了几个小时才让它发挥作用。

wordpress advanced-custom-fields acfpro

1
推荐指数
1
解决办法
3370
查看次数

如何在 WP_Query 循环中使用 'post_type' =&gt; 'product' 显示 ACF

尝试实现这一目标:我在 WooCommerce 产品中创建了一个 ACF(自定义字段),现在我尝试使用以下代码在我的模板中显示该字段:

 <ul class="products">
    <?php

    $args = array(
        'posts_per_page' => 20,
        'post_type' => 'product',
        'tax_query' => array(
            array(
                'taxonomy' => 'product_type',
                'field'    => 'name',
                'terms'    => 'grouped',
            ),
        ),
    );
    $loop = new WP_Query( $args );
    if ( $loop->have_posts() ) {
        while ( $loop->have_posts() ) : $loop->the_post();
            $linked_with_items = the_field('linked_with_items');
            the_title('<strong>', '</strong>'); echo '<br />';
            echo $linked_with_items;
        endwhile;
    } else {
        echo __( 'No products found' );
    }
    wp_reset_postdata();
    ?>
</ul><!--/.products-->
Run Code Online (Sandbox Code Playgroud)

但无论我尝试使用 get_field() ,该字段都不会显示在我的模板中。有人可以帮忙吗? https://www.advancedcustomfields.com/

这是最终代码仅供参考

 <?php if( …
Run Code Online (Sandbox Code Playgroud)

wordpress advanced-custom-fields

1
推荐指数
1
解决办法
3659
查看次数

如何在我的网站前端显示高级自定义字段插件的Google Map字段?

我使用了高级自定义字段插件的Google Map字段来输入我网站后端的地图值.任何人都可以建议我在我网站的前端显示它的最佳方式吗?

map advanced-custom-fields

0
推荐指数
2
解决办法
1万
查看次数

wp-login.php上的ACF错误

我正在使用Wordpress 4.3.1并使用ACF(高级自定义字段)5.3.0.我在"wp-login.php"中有以下错误.

警告:call_user_func()要求参数1是有效的回调函数,找不到函数'strrev'或/ www/htdocs/w00e3b8f/wp-content/plugins/advanced-custom-fields-pro/core/field中的函数名无效. php在319行

警告:call_user_func()要求参数1是有效的回调函数,找不到函数'strrev'或/ www/htdocs/w00e3b8f/wp-content/plugins/advanced-custom-fields-pro/core/field中的函数名无效. php在320行

警告:call_user_func()要求参数1是有效的回调函数,找不到函数'strrev'或/ www/htdocs/w00e3b8f/wp-content/plugins/advanced-custom-fields-pro/core/field中的函数名无效. php在325行

警告:call_user_func()要求参数1是有效的回调,没有在第326行的/www/htdocs/w00e3b8f/wp-content/plugins/advanced-custom-fields-pro/core/field.php中给出的数组或字符串

警告:call_user_func()要求参数1是有效的回调函数,找不到函数'strrev'或/ www/htdocs/w00e3b8f/wp-content/plugins/advanced-custom-fields-pro/core/field中的函数名无效. php在327行

警告:无法修改标题信息 - 已经/ www/htdocs /中已发送的标题(输出从/www/htdocs/w00e3b8f/wp-content/plugins/advanced-custom-fields-pro/core/field.php:319开始)第328行的w00e3b8f/wp-content/plugins/advanced-custom-fields-pro/core/field.php

你知道如何解决这些错误吗?

php validation wordpress advanced-custom-fields

0
推荐指数
1
解决办法
982
查看次数

使用WP和ACF动态添加.carousel-indicators到Bootstrap Carousel

我在Bootstrap/WP中有一个旋转木马工作正常,但是当添加更多"幻灯片"时,不会创建轮播指示器."幻灯片"是从ACF中提取的文本字段.如何使旋转木马指示器动态,以便每增加一个新的ACF条目?

<div id="myCarousel" class="carousel slide" data-ride="carousel">
      <!-- Indicators -->

      <ol class="carousel-indicators">
        <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
        <li data-target="#myCarousel" data-slide-to="1"></li>
        <li data-target="#myCarousel" data-slide-to="2"></li>
      </ol><h1>Testimonials</h1>
      <div class="carousel-inner" role="listbox">

          <?php // check if the repeater field has rows of data

            $count = 0;

            if( have_rows('testimonials') ){
                //loop through
                while ( have_rows('testimonials') ){
                //define the row
                the_row();
                   ?> 
                <div class="item 
                    <?php if ($count==0) {echo "active";} ?>"
                >
                    <div class="container">
                         <div class="carousel-caption">
                         <p><?php the_sub_field('testimony') ?></p>
                         <p><?php the_sub_field('name') ?></p>

                    </div>
                </div>
        </div>
        <?php
            $count=$count+1;
            }
            }
            ?> …
Run Code Online (Sandbox Code Playgroud)

wordpress carousel twitter-bootstrap-3 advanced-custom-fields

0
推荐指数
1
解决办法
2960
查看次数

Display ACF field inside posts loop in category.php

OK, so I need to display ACF custom field inside my posts loop in my custom category.php file. Here is the loop:

<div class="container">
<div class="row">

<?php
if ( have_posts() ) : ?>
<?php
/* Start the Loop */
while ( have_posts() ) : the_post();
?>

<div class="col-xs-12 col-sm-4">
    <?php the_title( '<h2><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' ); ?>
    <div><?php MY_ACF_FIELD_GOES_HERE ?></div>
</div> 

<?php 
/* End the Loop */    
endwhile;
?>
</div><!-- .row -->
</div><!-- .container …
Run Code Online (Sandbox Code Playgroud)

php wordpress advanced-custom-fields

0
推荐指数
1
解决办法
31
查看次数

ACF get_field不返回值

我试图使用get_field返回一个简单的文本字段,由于某种原因它返回空。字段本身就是应该存在的位置,并且其中包含文本,因此该部分已全部设置好。该PHP代码是通过php代码段加载的,例如,发布缩略图,可以完美显示。因此,除ACF字段值外,其他所有东西都起作用。

<div class="your-class">
    <?php
    $args = array(
        'post_type' => 'home_test',
        'posts_per_page' => -1,
        'orderby'   => 'name',
        'order'     => 'ASC',
    );
    $the_query = new WP_Query($args);
    $brand = get_posts($args);
    foreach ($brand as $post) {
        setup_postdata($post);
        $thumbnail = get_the_post_thumbnail_url($post->ID, 'full');

        $homelinkvalue = get_field("home_brand_link");

        if (!$thumbnail)
            continue;
        ?>
        <div>
            <p><?php echo $homelinkvalue; ?></p><img src="<?php echo $thumbnail; ?>">
        </div>

    <?php
    }
    wp_reset_postdata();
    ?>
</div>
Run Code Online (Sandbox Code Playgroud)

wordpress loops advanced-custom-fields

0
推荐指数
1
解决办法
110
查看次数