1st Jun '22
/
2 comments

Testimonials Slider in Bricks

Testimonials Slider in Bricks

This Pro tutorial provides the steps to set up a dynamic testimonial slider in Bricks that pulls the data from a Custom Post Type's post fields and custom fields.

Main text → CPT item post content

Image → CPT item featured image

Name → CPT item post title

Position → CPT item's testifier_position custom field value

Star rating → based on CPT item's rating custom field value. If 5 is selected in the select field's dropdown, 5 stars will be output. If 4 is selected, 4 stars will be output and so on..

Step 1

Create a testimonial CPT using a plugin like CPT UI.

Step 2

Install and activate ACF.

If you would like to import the field group from our demo site, here's the json file.

Create a new field group.

Add a new field of type Text whose Field Name is testifier_position.

Add another field of type Select whose Field Name is rating.

Set the Choices to:

1 2 3 4 5

Set the Default Value to

5

Under Location, associate the field group with your Testimonial CPT.

click to enlarge

Step 3

Add Testimonials.

Enter/set the title, content, position, rating and featured image for each.

Step 4

Let us define a custom function that returns the HTML for stars output based on the passed-in rating argument.

In your child theme's functions.php or a snippets plugin like WPCodeBox, add:

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 610 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Pro
ACF Group Sub Field Values from Matching Post Term

ACF Group Sub Field Values from Matching Post Term

In Bricks Reddit, a user asks: Let's break this down and set up the scenario practically. First, there's a Language taxonomy for posts (could be…
Categories:
Pro
Upcoming Events Grouped by ‘Month Year’ in Bricks

Upcoming Events Grouped by ‘Month Year’ in Bricks

A custom query loop type for showing future events based on a date custom field using three nested query loops.
Pro
Category Grid with ACF Images in Bricks

Category Grid with ACF Images in Bricks

Creating a grid of post categories, each category card showing an image from an ACF field, category name & description.
Categories:
Pro
Programmatically populating ACF field values in WordPress

Programmatically populating ACF field values in WordPress

An example of how to set the values of a Select-type field with the names and labels of all public post types.
Categories:
Pro
Bricks Dynamic Data Tag for Text-type Custom Field Value with Word Limit

Bricks Dynamic Data Tag for Text-type Custom Field Value with Word Limit

How to register a new dynamic tag for setting excerpt word limits and outputting an ellipsis (...) at the end.
Categories: