0
votes

In my project, backend is Wordpress and frontend is Laravel. I have installed “Advanced Custom Fields” plugin to Wordpress becase I want to make some sections dynamic. In normal wordpress site we are getting ACF fields as follows.

<?php
   $title = get_field('title', $id);
?>
   <h2> <?php echo $title; ?></h2>

But in a Laravel site, I cannot get Advanced Custom Fields in that manner. Does anyone know a way to get Wordpress backend added Advanced Custom Fields to Laravel frontend?

Thank you.

2
What ?! What are you trying to do really ... ? - Vincent Decaux
you can't get that ACF in laravel. - Krupal Panchal
Backend is Wodpress and Frontend is Laravel. Those are connected with Rest API. I want to create dynamic Testimonial section (Not a hard-code one). So I installed ACF plugin to create that testimonial section. Now I want to make those sections visible in Laravel site. Think there is a title which is added by ACF. I want to make it visible in Laravel. @VincentDecaux - Mayuri
Is that so.. ok thanks. So do you know a way to create dynamic sections from Laravel? @KrupalPanchal - Mayuri
Have a look on this : github.com/airesvsg/acf-to-rest-api - Sami

2 Answers

0
votes

First of all get_field() function is ACF's function and that won't be available on your Laravel project on front-end.

Steps : 1) Check if your ACF fields are being saved in your WordPress connected database. i.e MySQL.

2) if it's getting saved in your WordPress connected database then check if you are sending that value with your API response. Just check the response of your API. If not then you will have to add the get_field() returned value into your API response.

//Let's say 
$response = $responseData[];
//then just add 
$responseData['acf_field_title'] = get_field('title');
//and then send the response.

3) Now your ACF value is coming in API's response, your can simply call and use it's stored value.

I hope this helps you.

0
votes

You might want to check out Laraish, a WordPress theme that uses Laravel, and ACF integration works out of the box.