Support

Account

Home Forums General Issues Some posts hiccup with a different ACF structure

Unread

Some posts hiccup with a different ACF structure

  • I have a CPT with various ACF fields, including taxonomy and file. You can see it in action at: http://oicjapan.org/message (Yeah, I’m developing a live site – I have no choice.) A few of the posts (one in English and about ten in Japanese, even though they are supposed to be identical duplicates – go figure!) act differently than the rest. Normally get_field() on a taxonomy is an object and get_field() on a file type is a string (the URL to the file). But in the case of the weird posts, get_field(taxonomy) is just an integer of the taxonomy ID, and get_field(file) is an array! Here are real var_dump’s from inside the post loop, for an example normal post and an example weird one:

    A normal one is ID#4938 – Taxonomy get_field(‘preacher’,4938) looks like this:

    object(stdClass)#4021 (10) {
      ["term_id"]=>
      int(89)
      ["name"]=>
      string(12) "Brian Bluett"
      ["slug"]=>
      string(12) "brian-bluett"
      ["term_group"]=>
      int(0)
      ["term_taxonomy_id"]=>
      int(106)
      ["taxonomy"]=>
      string(16) "message_preacher"
      ["description"]=>
      string(22) "Interim Pastor in 2014"
      ["parent"]=>
      int(0)
      ["count"]=>
      int(0)
      ["filter"]=>
      string(3) "raw"
    }

    And get_field(‘audio_file’) is simply the path to the file:

    string(72) "http://oicjapan.org/wp-content/uploads/older-sermons/misc/2014-10-19.mp3"

    A weird one is ID#4943 – Taxonomy get_field(‘preacher’,4943) is just the ID:

    int(89)

    And get_field(‘audio_file’) is an array:

    array(8) {
      ["ID"]=>
      int(3993)
      ["id"]=>
      int(3993)
      ["alt"]=>
      string(0) ""
      ["title"]=>
      string(10) "2014-10-12"
      ["caption"]=>
      string(0) ""
      ["description"]=>
      string(0) ""
      ["mime_type"]=>
      string(10) "audio/mpeg"
      ["url"]=>
      string(72) "http://oicjapan.org/wp-content/uploads/older-sermons/misc/2014-10-12.mp3"
    }

    Anytime a post has this hiccup, all taxonomy fields and all file fields act this way – it is consistent within a given post.

    Since there are only a few weird ones, I assume I can just make them again from scratch, but soon I’ll be mostly entrusting the site maintenance to non-techies, so I would like to know what is causing it so that I can prevent it either by code or training.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.