admin管理员组

文章数量:1318032

I am trying to get the below action to display on an archive page on my site via Code Snippets:

add_action( 'woocommerce_after_shop_loop', 'test_text', 42);

function test_text() {
    the_field('group_5f7ee777725c8', 42);
}

This is a hook for Advanced Custom Fields to display some basic text on an archive page (product_cat), ACF support say that this should work - but I cannot get it to display. ACF support have stressed that I need to look at how I am implementing this code, but I can see nothing wrong with implementing this how I am trying (Code Snippets).

Am I missing something here?

I am trying to get the below action to display on an archive page on my site via Code Snippets:

add_action( 'woocommerce_after_shop_loop', 'test_text', 42);

function test_text() {
    the_field('group_5f7ee777725c8', 42);
}

This is a hook for Advanced Custom Fields to display some basic text on an archive page (product_cat), ACF support say that this should work - but I cannot get it to display. ACF support have stressed that I need to look at how I am implementing this code, but I can see nothing wrong with implementing this how I am trying (Code Snippets).

Am I missing something here?

Share Improve this question edited Oct 20, 2020 at 9:19 Rup 4,4004 gold badges29 silver badges29 bronze badges asked Oct 20, 2020 at 7:00 DanDan 1 2
  • What is the field named "group_5f7ee777725c8"? And is there a post with ID: 42? – vadims Commented Oct 20, 2020 at 9:05
  • I don't know Code Snippets: where does it run? Will this hook definitely be in place before it's called? You could e.g. add an error_log or some other echo to the code to verify it is actually called. Can you try editing this into your theme's functions.php temporarily to see if that works instead? – Rup Commented Oct 20, 2020 at 9:20
Add a comment  | 

1 Answer 1

Reset to default 0

You try to access to an ACF group of fields group_5f7ee777725c8 and the function the_field need a field key (not the group key).

You shoud replace group_5f7ee777725c8 with the field key you'll find inside the group. So in ACF menu click on the group group_5f7ee777725c8 and find the field key. It should start with field_XXXXX

本文标签: themesI cannot get an Advanced Custom Field code snippet to workand ACF support say it should work