Ad

Out Putting RAW ACF Values In Twig/timber Unto Page Header For SEO Purposes

- 1 answer

So, from ACF I have created my own SEO fields in my custom WP theme, so I don't have to rely on a plugin, and I want to have the default values already filled out, so we don't always have be doing that unless for something specific - how do I out put those unto my page and insert them in the header at the same time? I have tried {{post.meta_description|raw}} and {{ function('wp_head') }}timber but it just prints it on the page, what am I missing?

Another great {{ post.tool_brand }} {{ post.tool.type}} 
for sale, {{ post.power_type }} of power with a 
competitive price {{ post. tool_price }}!

acf seo fields

{% extends "base.twig" %}

{% block content %}
    <div class="container my-4">
        <head>
            {{post.meta_description|raw}}
            {{ function('wp_head') }}
        </head>
    </div>

{% endblock %}

actual output

Ad

Answer

This here seems to do exactly what I wanted it to do: {{ include(template_from_string(post.meta_description)) }}

ie: <meta name="description" content="{{ include(template_from_string(post.meta_description)) }}">

Ad
source: stackoverflow.com
Ad