I've created custom fields for a custom post-type using WCK plugin for the fields, and want to get the fields into my Timber Twig template. (I know Timber recommends ACF for this, but am trying WCK first, as this is for a non-profit website and WCK offers things in their free plugin version which ACF doesn't). Here is the relevant line of the php file:
$context['home_page_content'] = Timber::get_posts('post_type=vopthomepage');
and in my twig template I printed:
{{ dump(home_page_content) }}
The relevant parts (I think?) which I get are:
public 'object_type' => string 'post' (length=4)
public 'post_type' => string 'vopthomepage' (length=12)
public 'are_you' => // this is the field group
public 'question_1' => string 'New to the area, looking for a church to join?' (length=46) // this is the field
So to get the field I tried {{ post.question_1 }}
, no joy, so then tried {{ post.get_field('question_1') }}
I also tried following the advice for ACF with {{ post.meta('are_you').question_1 }}
but none of these prints anything on the page.
Here's the full dump:
array (size=1)
0 =>
object(Timber\Post)[5652]
public 'ImageClass' => string 'Timber\Image' (length=12)
public 'PostClass' => string 'Timber\Post' (length=11)
public 'TermClass' => string 'Timber\Term' (length=11)
public 'object_type' => string 'post' (length=4)
public 'custom' =>
array (size=7)
'_edit_last' => string '1' (length=1)
'_edit_lock' => string '1583704531:1' (length=12)
'are_you' =>
array (size=1)
...
'_rsc_content_availability' => string 'everyone' (length=8)
'_rsc_capability' => string '' (length=0)
'question_1' => string 'New to the area, looking for a church to join?' (length=46)
'answer_1' => string 'Take a look under the What we do menu, as well as Churches for info and the locations of buildings.' (length=99)
protected '___content' => null
protected '_permalink' => null
protected '_next' =>
array (size=0)
empty
protected '_prev' =>
array (size=0)
empty
protected '_css_class' => null
public 'id' => int 293
public 'ID' => int 293
public 'post_author' => string '1' (length=1)
public 'post_content' => string '' (length=0)
public 'post_date' => string '2020-03-04 16:42:52' (length=19)
public 'post_excerpt' => string '' (length=0)
public 'post_parent' => int 0
public 'post_status' => string 'publish' (length=7)
public 'post_title' => string 'Home page content' (length=17)
public 'post_type' => string 'vopthomepage' (length=12)
public 'slug' => string 'help' (length=4)
protected '__type' => null
public '_edit_last' => string '1' (length=1)
public '_edit_lock' => string '1583704531:1' (length=12)
public 'are_you' =>
array (size=1)
0 =>
array (size=2)
...
public '_rsc_content_availability' => string 'everyone' (length=8)
public '_rsc_capability' => string '' (length=0)
public 'question_1' => string 'New to the area, looking for a church to join?' (length=46)
public 'answer_1' => string 'Take a look under the What we do menu, as well as Churches for info and the locations of buildings.' (length=99)
public 'post_date_gmt' => string '2020-03-04 16:42:52' (length=19)
public 'comment_status' => string 'closed' (length=6)
public 'ping_status' => string 'closed' (length=6)
public 'post_password' => string '' (length=0)
public 'post_name' => string 'help' (length=4)
public 'to_ping' => string '' (length=0)
public 'pinged' => string '' (length=0)
public 'post_modified' => string '2020-03-08 21:08:08' (length=19)
public 'post_modified_gmt' => string '2020-03-08 21:08:08' (length=19)
public 'post_content_filtered' => string '' (length=0)
public 'guid' => string 'https://mbp-2.local:5757/?post_type=vopthomepage&p=293' (length=65)
public 'menu_order' => int 0
public 'post_mime_type' => string '' (length=0)
public 'comment_count' => string '0' (length=1)
public 'filter' => string 'raw' (length=3)
public 'status' => string 'publish' (length=7)
{{ home_page_content.question_1 }}
– Henrik Erstad{{ dump(home_page_content) }}
? – Henrik Erstad