PHP WordPress function / module display issue?
one text
I'm working in an environment in VS Code and running my work on a sever with npm run watch
command. I am referencing the files themselves in my functions.php file, I can choose the module in the wordpress admin panel, but I cannot actually get my 'testimonials_1' field to pop up on the preview page. That's the only piece I'm trying to get right now.
My functions file
<?php
function module_testimonials_acf() {
return array(
'key' => 'testimonials_module',
'name' => 'testimonials_module',
'label' => 'Testimonials',
'display' => 'block',
'sub_fields' => array(
array(
'key' => 'testimonials_repeater_1',
'name' => 'testimonials_repeater_1',
'label' => 'First Testimonial',
'type' => 'repeater',
'min' => 1,
'max' => 1,
'layout' => 'block',
'return_format' => 'array',
'required' => 0,
'sub_fields' => array(
array(
'key' => 'testimonials_paragraph_1',
'name' => 'testimonial_1',
'label' => 'Testimonial 1',
'type' => 'textarea',
'instructions' => 'The testimonial goes here.',
'required' => 1,
'wrapper' => array(
'width' => '40'
)
),
array(
'key' => 'testimonials_product_description_1',
'name' => 'testimonials_product_description_1',
'label' => 'Product Description 1',
'type' => 'textarea',
'instructions' => 'The product description goes here. (Product info, color, location)',
'required' => 1,
'wrapper' => array(
'width' => '40'
)
),
array(
'key' => 'testimonial_image_1',
'name' => 'testimonial_image_1',
'label' => 'Testimonial Image 1',
'type' => 'image',
'instructions' => 'Testimonial Background Image',
'required' => 1,
'return_format' => 'url',
'preview_size' => 'medium',
'min_width' => '100',
'wrapper' => array(
'width' => '20'
)
)
)
),
array(
'key' => 'testimonials_2',
'name' => 'testimonials_2',
'label' => 'Testimonials 2',
'type' => 'repeater',
'min' => 1,
'max' => 1,
'layout' => 'block',
'return_format' => 'array',
'required' => 0,
'sub_fields' => array(
array(
'key' => 'testimonials_paragraph_2',
'name' => 'testimonials_paragraph_2',
'label' => 'Testimonial 2',
'type' => 'textarea',
'instructions' => 'The testimonial goes here.',
'required' => 1,
'wrapper' => array(
'width' => '40'
)
),
array(
'key' => 'testimonials_product_description_2',
'name' => 'testimonials_product_description_2',
'label' => 'Product Description 2',
'type' => 'textarea',
'instructions' => 'The product description goes here. (Product info, color, location)',
'required' => 1,
'wrapper' => array(
'width' => '40'
)
),
array(
'key' => 'testimonial_image_2',
'name' => 'testimonial_image_2',
'label' => 'Testimonial Image 2',
'type' => 'image',
'instructions' => 'Testimonial Background Image',
'required' => 1,
'return_format' => 'array',
'preview_size' => 'medium',
'min_width' => '1800',
'wrapper' => array(
'width' => '20'
)
)
)
),
array(
'key' => 'testimonials_3',
'name' => 'testimonials_3',
'label' => 'Testimonials 3',
'type' => 'repeater',
'min' => 1,
'max' => 1,
'layout' => 'block',
'return_format' => 'array',
'required' => 0,
'sub_fields' => array(
array(
'key' => 'testimonials_paragraph_3',
'name' => 'testimonials_paragraph_3',
'label' => 'Testimonial 3',
'type' => 'textarea',
'instructions' => 'The testimonial goes here.',
'required' => 1,
'wrapper' => array(
'width' => '40'
)
),
array(
'key' => 'testimonials_product_description_3',
'name' => 'testimonials_product_description_3',
'label' => 'Product Description 3',
'type' => 'textarea',
'instructions' => 'The product description goes here. (Product info, color, location)',
'required' => 1,
'wrapper' => array(
'width' => '40'
)
),
array(
'key' => 'testimonial_image_3',
'name' => 'testimonial_image_3',
'label' => 'Testimonial Image 3',
'type' => 'image',
'instructions' => 'Testimonial Background Image',
'required' => 1,
'return_format' => 'array',
'preview_size' => 'medium',
'min_width' => '1800',
'wrapper' => array(
'width' => '20'
)
)
)
)
)
);
}
?>
My php file with the html in it
<div class="highlight-testimonials">
<div class="parallax" id="behind-content"></div>
<div class="testimonials">
<div class="wrap">
<div class="testing">
<div class="test-intro">
<h3>Testimonials</h3>
<p>See what our customers have to say about their Metal roofs.</p>
<a class="primary-cta" href="#">Start your own project<div class="material-icons">east</div></a>
</div>
<?php
$testimonial_1 = mod_get_field('testimonial_1');
?>
<div class="three-examples">
<div class="col individual-card">
<div class="display-img">
<img src="#" alt=" metals testimonial photo"/>
</div> <!-- .display-img -->
<div class="text-area">
<img class="quo" src="/images/quotes.svg"/>
<p class="p1"><?php echo $testimonial_1 ?></p>
<p>Product information goes here, product, color and location</p>
</div> <!-- .text-area -->
</div> <!-- .col -->
</div> <!-- .three-examples .row -->
</div> <!-- .testing -->
</div> <!-- .wrap-->
</div> <!-- .testimonials -->
</div> <!-- .highlight-testimonials -->
<tr>
<td>
</td>
</tr>
Source