A Cozmoslabs Product
Documentation / Custom Fields Creator / How to / Display a Custom Field

Display a Custom Field

To display Custom Fields values we use the function the_cfc_field().

For a Single Meta Box

In The Loop:

1
2
3
4
5
/* 
 *Let's say we want to display the field Last Name (the slug will be last-name) from a Single Meta Box  
 */
 
Name: <?php the_cfc_field('my_meta_name', 'last-name'); ?>

Outside The Loop:

1
2
3
4
5
6
/*
 * Let's say we want to display the field Description (the slug will be description) 
 * From a Single Meta Box, from the post with id 46 
 */
 
Description: <?php the_cfc_field('my_meta_name', 'description', 46 ); ?>

For a Repeater Meta Box

Besides the function the_cfc_field() for a repeater we also need get_cfc_meta() function.

In The Loop:

1
2
3
4
5
6
7
/* 
 * Let's say we want to display all the fields Last Name (the slug will be last-name) from a Repeater Meta Box  
 */
 
<?php foreach( get_cfc_meta( 'my_meta_name' ) as $key => $value ){ ?>
    Name: <?php the_cfc_field( 'my_meta_name','last-name', false, $key ); ?>
<?php }  ?>

Outside The Loop:

1
2
3
4
5
6
7
8
/*
 * Let's say we want to display all the fields Description (the slug will be description) 
 * From a Repeater Meta Box, from the post with id 46 
 */
 
<?php foreach( get_cfc_meta( 'my_meta_name' ) as $key => $value ){ ?>
    Description: <?php the_cfc_field( 'my_meta_name','description', 46, $key ); ?>
<?php }  ?>

The Ultimate Membership Bundle

Combine the power of Profile Builder with Paid Member Subscriptions to set up user

Get 25% off with the bundle

Help & Support

We’re here to help you every step of the way.

Open a Support Ticket