Template Usage #
You have to specify the type inside the array key called type. The type must be as ‘checkbox‘. Don’t misspell the word. The default key will be an array of values which have to be matched with the keys of options field.
<?php
array( 'label' => esc_html__( 'Files Included', 'pure' ), 'id' => "{$prefix}_files_options", 'type' => 'checkbox', 'default' => array( 'wordpress', 'react', 'html', 'psd', 'vue' ), 'options' => array( 'wordpress' => 'Wordpress File Included?', 'react' => 'React File Included?', 'html' => 'HTML File Included?', 'psd' => 'PSD Included?', 'vue' => 'Vue JS File Included?' ) )
?>
How to fetch the data? #
Use our function called tpmeta_field(‘_your_id’) and pass the above array id key to fetch the metadata. Since the function tpmeta_field(‘_your_id’) will return an array so you can check with isset() function. Check if the key exist in the array.
<?php $value = function_exists('tpmeta_field')? tpmeta_field('meta_key_id_here') : '';
echo isset($value['options_key'])? //code : //another code;//or you can use if
if(isset($value['options_key'])){
// code
} ?>