microb14
microb14

Reputation: 483

Wordpress - Insert ACF php

I need to insert get_field ACF into PHP code

<?php 
$not_human       = "test1";
$missing_content = "test2";
$email_invalid   = "test3";
$message_unsent  = "test4";
$message_sent    = "test5";
?>

i need to replace test1 by

<?php the_field( 'titre' ); ?>

thank you

Upvotes: 0

Views: 584

Answers (1)

iismaell
iismaell

Reputation: 633

You should use the get_field function instead of the the_field.

// https://www.advancedcustomfields.com/resources/get_field/

Example:

<?php 
$not_human       = get_field("titre");
?>

To echo the value of the $not_human variable containing the custom field titre, do this.

<?php 
$not_human       = get_field("titre");
echo $not_human;
?>

The the_field function should also work but it looks like you wanted to bind the custom field value to a variable, which is why the get_field function is suggested.

Upvotes: 1

Related Questions