logo
logo
logo
  • Home
  • Documentation
  • Support
Get PMF Free

How to print or display or fetch the data?

Getting Started

  • What is metafields?
  • Where to use it?
  • Some common use cases for metafields include
  • What about our plugin?

Installations

  • Automatic install from wordpress dashboard
  • Manual install from wordpess dashbaord
  • Install Using FTP

Configs

  • How to use or add?
  • How to print or display or fetch the data?
  • Usage

Fields

  • Text
  • Textarea
  • Switch
  • Tabs
  • Checkbox
  • Select
  • Image
  • Gallery
  • Datepicker
  • Colorpicker
  • Repeater

Go Pro

  • What is included in pro version?
  • Go Pro

FAQs

  • What is a meta box in WordPress?
  • Why do I need a meta box plugin?
  • Can I create multiple meta boxes?
  • Home
  • Docs
  • Configs
  • How to print or display or fetch the data?

How to print or display or fetch the data?

GET THE META VALUE FOR CURRENT POST #

<?php
$value = function_exists('tpmeta_field')? tpmeta_field('meta_key_id_here') : '';
?>

GET THE META VALUE FOR SPECIFIC POST #

<?php
$value = function_exists('tpmeta_field')? tpmeta_field('meta_key_id_here', $post_id) : '';
?>

GET GALLERY IMAGES #

<?php
$tp_gallery_images = function_exists('tpmeta_gallery_field') ? tpmeta_gallery_field('gallery_meta_key') : ''; //tpmeta_gallery_field($string_ids, $size)

foreach($tp_gallery_images as $single_image_src){
    echo $single_image_src['url'] ."<br>";
    echo $single_image_src['alt'] ."<br>";
}
?>

GET SINGLE IMAGE #

<?php
$tp_image = function_exists('tpmeta_image_field') ? tpmeta_image_field('image_meta_key') : ''; // tpmeta_image_field($id, $size)

echo $tp_image['url'];
echo $tp_image['alt'];
?>

GET REPEATER DATA #

<?php
$tp_repeater = function_exists('tpmeta_field') ? tpmeta_field('repeater_meta_key') : ''; // tpmeta_field($meta_key, $post_id)

foreach($tp_repeater as $row){ // Iterate the data with loop
    echo $row['repeater_sub_field_key'] // get the subfield value by repeater inner array field key
}
?>

ACCESS SINGLE IMAGE AND GALLERY IMAGES INSIDE REPEATER #

<?php
$tp_repeater = function_exists('tpmeta_field') ? tpmeta_field('repeater_meta_key') : ''; // tpmeta_field($meta_key, $post_id)

foreach($tp_repeater as $row){ // Iterate the data with loop

     $gallery = tpmeta_gallery_images($row['repeater_sub_field_key'], 'image_size'); 

     $image = tpmeta_image($row['repeater_sub_field_key'], 'image_size');
}
?>
What are your Feelings
Share This Article :
  • Facebook
  • Twitter
  • LinkedIn
  • Pinterest
Still stuck? How can we help?

How can we help?

Updated on October 3, 2023
How to use or add?Usage

Powered by BetterDocs

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Table of Contents
  • GET THE META VALUE FOR CURRENT POST
  • GET THE META VALUE FOR SPECIFIC POST
  • GET GALLERY IMAGES
  • GET SINGLE IMAGE
  • GET REPEATER DATA
  • ACCESS SINGLE IMAGE AND GALLERY IMAGES INSIDE REPEATER

Copyright © 2023 Pure Metafields. All Rights Reserved