cf_custom_fields_get_post_type_entry
Render saved entry when editing posts.
Description
Returns (array)
Parameters (3)
- 0. $data (array)
- Rendered data.
- 1. $form (array)
- Form config.
- 2. $entry_id (string)
- The entry id.
Usage
if ( !function_exists( 'cf_custom_fields_get_post_type_entry' ) ) { require_once ABSPATH . PLUGINDIR . 'caldera-custom-fields/includes/to-post-type.php'; } // Rendered data. $data = array(); // Form config. $form = array(); // The entry id. $entry_id = ''; // NOTICE! Understand what this does before running. $result = cf_custom_fields_get_post_type_entry($data, $form, $entry_id);
Defined (1)
The function is defined in the following location(s).
- /includes/to-post-type.php
- function cf_custom_fields_get_post_type_entry($data, $form, $entry_id) {
- if($processor = cf_custom_fields_has_pr_processor($form, $entry_id)) {
- $fields = $form['fields'];
- $data = array();
- $data[$fields[$processor['config']['post_title']]['slug']] = $processor['post']->post_title;
- unset($fields[$processor['config']['post_title']]);
- if(!empty($processor['config']['post_content'])) {
- $data[$fields[$processor['config']['post_content']]['slug']] = $processor['post']->post_content;
- unset($fields[$processor['config']['post_content']]);
- }
- foreach($fields as $field) {
- $data[$field['slug']] = get_post_meta( $processor['post']->ID, $field['slug'], true );
- }
- }
- return $data;
- }