Count of Images in Meta Box Image Advanced Field

In the BricksLabs Facebook group a user asks:

Is there a way to count images inside a post that uses metabox image upload ?

This Pro tutorial provides the code for getting the count of the number of images in an Image Advanced type of custom field created using Meta Box.

We are going to define a custom function and can then use it with the Dynamic data tag in Bricks to, for example, conditionally render a Section only if there is at least one image uploaded/selected to/for the field.

with the Dynamic data being

{echo:bl_get_image_count_image_advanced(image_advanced_vsoh9ful7jb)}

where image_advanced_vsoh9ful7jb is the field ID.

Add the following in child theme's functions.php (w/o the opening PHP tag) or a code snippets plugin:

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 524 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Pro
Sort Posts by Meta Box Group Sub Field in Bricks

Sort Posts by Meta Box Group Sub Field in Bricks

This Pro tutorial provides the steps to order posts in Bricks by the value of a Number-type of sub field that is inside a Meta…
Pro
Dynamic Accordion in WordPress using Meta Box and Alpine.js

Dynamic Accordion in WordPress using Meta Box and Alpine.js

This Pro tutorial provides the steps to implement an accordion using Alpine.js in WordPress that pulls the values of sub fields of a Meta Box…
Pro
Condition to Check if the Current Category Has At Least One Child

Condition to Check if the Current Category Has At Least One Child

Looking to render an element in the category archive Bricks template only if the category of the current category archive page is a parent? This…
Categories:
Pro
Conditionally outputting an element in a Query Loop based on date-type custom field

Conditionally outputting an element in a Query Loop based on date-type custom field

This Pro tutorial shows how to output an element in a Bricks' query loop only if the value of a date-type of custom field for…
Categories:
Pro
Custom Dynamic Data Tags in Bricks

Custom Dynamic Data Tags in Bricks

In the BricksLabs Facebook group a user asks: Is there a way to count images inside a post that uses metabox image upload ? This…