lundi 18 avril 2016

Timber: Access Advanced Custom Field From Another Page

I am trying to access ACF data from another page to be displayed on another.

The ACF name is the_unstrung_hero in the "About" page (id = 7).

page-home.php:

<?php
$context = Timber::get_context();
$post = new TimberPost();
$about_page_id = 7;
$about = new TimberPost($about_page_id);
$about->acf = get_field_objects($about->ID);
$context['post'] = $post;
Timber::render( array( 'page-' . $post->post_name . '.twig', 'page.twig' ), $context );

Within page-home.twig:

<p>{{ acf.the_unstrung_hero|print_r }}</p>

This is just the last combination attempt of many. Frankly I am just not getting something (PHP is not a forte of mine)... Your help will be greatly appreciated.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire