0
Welcome Guest! Login
0 items Join Now

SOLVED Accessing custom fields from Advanced Custom Fields plugin

    • CCDW's Avatar
    • CCDW
    • Rocketeer
    • Posts: 62
    • Thanks: 0

    SOLVED Accessing custom fields from Advanced Custom Fields plugin

    Posted 9 years 6 months ago
    • Accessing custom fields from Advanced Custom Fields plugin

      Hi Guys

      I have added Advanced Custom Fields plugin to my site and I want to include the fields in the page content particle.

      I have looked at content-page.html.twig and want to render below this:

      {# Begin Page Content #}
      {{ post.content }}


      The function I usually use from Advanced Custom Fields plugin in my other themes is:

      the_field('custom_field_name')

      but I get an error saying:

      The function "the_field" does not exist in "partials/content-page.html.twig"

      How do I add a reference to the the_field function so that I can use it in partials/content-page.html.twig ?

      Here's a link to Advanced Custom Fields below. As I say, I use it no prob in other themes, but not sure how to reference it in Twig. All new to me.

      www.advancedcustomfields.com/resources/d...alues-in-your-theme/

      Ps, can you show me documentation so that I can debug Gantry code/templates?

      Thanks again

      Chris
    • Last Edit: 9 years 6 months ago by CCDW.
    • CCDW's Avatar
    • CCDW
    • Rocketeer
    • Posts: 62
    • Thanks: 0

    Re: SOLVED Accessing custom fields from Advanced Custom Fields plugin

    Posted 9 years 6 months ago
    • This message contains only secure information that is visible to CCDW, moderators and administrators
    • CCDW's Avatar
    • CCDW
    • Rocketeer
    • Posts: 62
    • Thanks: 0

    Re: SOLVED Accessing custom fields from Advanced Custom Fields plugin

    Posted 9 years 6 months ago
    • I will happily take out a paid support ticket if this can be solved quickly...
    • Last Edit: 9 years 6 months ago by CCDW.
    • CCDW's Avatar
    • CCDW
    • Rocketeer
    • Posts: 62
    • Thanks: 0

    Re: SOLVED Accessing custom fields from Advanced Custom Fields plugin

    Posted 9 years 6 months ago
    • I solved this myself thanks to:

      ACF Cookbook
    • Last Edit: 9 years 6 months ago by CCDW.
  • Re: SOLVED Accessing custom fields from Advanced Custom Fields plugin

    Posted 8 years 10 months ago
    • It would be helpful to others who view this to know how you solved it. I'm working on this myself now and I suspect that since I can manually enter a custom field from the post admin page and then use it the same as {{post.title}} as in {{ post.mycustomfield}} this seems to work fine so I imagine that the plugin version of this is the same since all the plugin does is make the set up of the custom field easier. The plugin still creates a custom field as if you manually made it in the admin page.

      So in summary if {{post.title}} outputs "My Title" then {{post.mycustomfield}} outputs "My Test Custom Field"
    • Last Edit: 8 years 10 months ago by RZN8 Media.

Time to create page: 0.072 seconds