Questions tagged [advanced-custom-fields]

Advanced Custom Fields is a free WordPress plugin which acts as a GUI layer for custom fields. Custom fields are native to WP and appear on pages, posts and custom post types, however the native custom field interface is not very user friendly. ACF uses field groups to attach fields to edit screens.

Advanced Custom Fields is a free WordPress plugin which acts as a GUI layer for custom fields. Custom fields are native to WP and appear on pages, posts and custom post types, however, the native custom field interface is not very user-friendly. ACF uses field groups to attach fields to edit screens.

More information and good documentation are available on the official website. The plugin can be downloaded from the WordPress plugin repository or installed from within the WordPress admin.

Useful Links

4522 questions
36
votes
2 answers

merge_array returns null if one or more of arrays is empty?

I will give you quick run down of what I am doing. I am using wordpress with the advanced custom fields plugin. This is a php based question because these get_field() fields contain object arrays. $gallery_location =…
Joshc
  • 3,825
  • 16
  • 79
  • 121
24
votes
8 answers

How to get Advanced Custom Fields field key from WordPress database?

I’m using Advanced Custom Fields with post-type. I have some select custom fields, and I want to show all the label choices from each field. I’ve tried this way. $field = get_field_object('hair_color'); $hair = $field["choices"]; foreach($hair…
user1432966
  • 523
  • 1
  • 9
  • 20
22
votes
3 answers

Get image from taxonomy term using ACF

I am using the below code to try and retrieve an image field called 'image' from a taxonomy term using the Advanced Custom Fields plugin. This code is based on the documentation on the ACF website here. It should be noted this code is being used…
dungey_140
  • 2,602
  • 7
  • 34
  • 68
20
votes
4 answers

How to expose all the ACF fields to Wordpress REST API in both pages and custom postypes

I want to expose all the ACF fields that belong to a page or custom post type to the WordPress REST API in order to do some API calls through javascript. The final expected result would be all the ACF fields inside an ACF object that you can easily…
Mel Macaluso
  • 3,250
  • 2
  • 12
  • 26
20
votes
4 answers

How can I restrict Two dates in ACF date picker for Starting date and Ending Date in Wordpress?

I have created an event post type in Wordpress. For that I have put starting date and ending date from ACF datepicker. I want admin can select Ending date greater than Starting Date. Is there any way for restricting Starting Date and Ending…
Jitendra Damor
  • 774
  • 17
  • 27
17
votes
8 answers

How to count the total number of rows in a ACF repeater output

Question: How do you simply count the rows in the output of an ACF repeater field? Goal: to make the output look different with a css class when there's only one row, vs. more than one row. My code: if( have_rows('testimonials')) { $counter =…
Robert
  • 744
  • 1
  • 5
  • 15
17
votes
3 answers

Wordpress: Advanced Custom Fields: Exporting and Importing fields to a new wordpress install

I've created two custom field groups in a temporary wordpress install and would now like to use the export of them to import them into a new wordpress install, however it doesn't seem like there's a way. How have others done this?
Reuben
  • 2,701
  • 6
  • 31
  • 47
17
votes
4 answers

Adding a character in the middle of a string

There's probably a simple solution to this that will cause a facepalm. I have time stored as a 4 character long string ie 1300. I'm trying to display that string as 13:00. I feel like there has to be a solution to this that is more elegant than what…
Baadier Sydow
  • 506
  • 1
  • 6
  • 19
15
votes
1 answer

Display product post type advanced custom field on recent orders template and admin orders (woocommerce)

I’m trying to display the fields I have created in the recent order template of WooCommerce and I’m not very knowledgeable in PHP. I have created a field called sessions and registered as a product post type. Once a user purchase a product I want…
clestcruz
  • 1,081
  • 3
  • 31
  • 75
15
votes
3 answers

Significance level of ACF and PACF in R

I want to obtain the the limits that determine the significance of autocorrelation coefficients and partial autocorrelation coefficients, but I don't know how to do it. I obtained the Partial autocorrelogram using this function pacf(data). I want…
Erincon
  • 389
  • 1
  • 7
  • 21
14
votes
5 answers

wordpress advanced custom fields google map api key

I have a problem with loading google map with the Advanced Custom Field plugin. I make everything like in the instruction on the plugin page here https://www.advancedcustomfields.com/resources/google-map. I add google-map field in ACF, but on the…
13
votes
4 answers

WordPress: Check if plugin is installed (ACF)

I want to prevent fatal error in my theme if the ACF plugin is deactivated or not installed. The main function of the plugin is get_field(). I wrote this code in my functions.php to check: if ( !function_exists('get_field') ) { function…
Joe
  • 353
  • 1
  • 3
  • 12
12
votes
3 answers

Using wc_get_product() with a PHP variable for product ID

I'm building out custom landing pages for products in WooCommerce and I'd like to get the product price amongst other things in order to display them on the landing page. Each landing page has some custom fields which allow the WP Admin to add in…
12
votes
2 answers

Wordpress ACF: How to add rows to a repeater field attached to a user via custom code (PHP)

I have been through the ACF and ACF Repeater Field documentation but it has left me a little bit confused. I have a bunch of users and I have (through ACF) attached a repeater field to each of them (called Events), the repeater field has a sub-field…
PavKR
  • 1,591
  • 2
  • 11
  • 26
9
votes
1 answer

The values in the ACF Repeater fields is null when the values for the same repeater field is updated in other languages?

I have a site in three languages and when I edit the repeater field for one of the languages, the value of the repeater field in other languages becomes null. This is only for some of the repeater fields in the site.
prajwal_stha
  • 357
  • 3
  • 17
1
2 3
99 100