AdvancedCustomFields / AdvancedCustomFields/acf

get_fields not returning all fields

Open
#456 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
945
Forks
197
PR merge metrics
No merged PRs in 30d

Description

I have a custom post type with about a dozen custom fields. Before rendering the template that displays this post type I create a new object with this constructor:

/**
	 * Initialize the class and set its properties.
	 *
	 * @param WP_Post|null $post
	 * @param array        $meta
	 * @param array        $fields
	 */
	public function __construct( ?WP_Post $post, array $meta, array $fields ) {
		$this->post   = $post;
		$this->meta   = $meta;
		$this->fields = $fields;
	}

I initialize the last arg with $fields = get_fields( $post_id ). When I run this in Xdebug, however, that $fields arg only contains a limited set of the total fields for that object. I have to instead run get_post_meta and work with the raw meta values instead.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reported get_fields($post_id) call and compare its returned fields with the values from get_post_meta. Confirm which custom fields are omitted and under what post conditions; done means get_fields returns the complete set of fields expected for the custom post type.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.