Support

Account

Home Forums General Issues Add Custom fields in a Twig template

Helping

Add Custom fields in a Twig template

  • Hello,

    My themes’ template files are made of TWIG template format. So, how to add those php codes inside these twig codes.

    Such as,

    This Php code,

    <img src="<?php the_field('profile_pic'); ?>" />

    into this Twig code

    {% extends 'layout.twig' %}
    
    {% block content %}
        <h1 class="page-header">{{ wp.__('tlts', 'aviators') }}</h1>
    
        <div class="our-agents-large">
            <div class="row-fluid">
                {% if wp.have_posts() %}
                    {% for post in posts %}
                        {{ wp_query.the_post() }}
                        {{ wp.get_template_part('content-tlt', wp.get_post_format()) }}
                        
                        {% if loop.index % 4  == 0 %}
                            </div><div class="row-fluid">
                        {% endif %}                    
                    {% endfor %}
                {% else %}
                    {{ wp.get_template_part('content', 'none') }}
                {% endif %}
            </div>
        </div><!-- /.our-agents-large -->
    
        {{ wp.aviators_paging_nav() }}
    {% endblock %}

    Any help will be appreciated…

  • Hi @TharinduLucky

    I am not familiar with ‘twig’, so I can’t provide much help other than to recomend that you contact the twig support, or read over the twig documentation to find out how you could use PHP in the template.

    If you are asking the question, chances are 100 people are experiencing it, so I’m confident you find the solution on google / twig website.

    Thanks
    E

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Add Custom fields in a Twig template’ is closed to new replies.