PHP code example of wpify / custom-fields
1. Go to this page and download the library: Download wpify/custom-fields library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
wpify / custom-fields example snippets
// Register a metabox with custom fields.
wpify_custom_fields()->create_metabox(
array(
'id' => 'project_details',
'title' => __( 'Project Details', 'my-plugin' ),
'post_types' => array( 'post' ),
'items' => array(
'project_name' => array(
'type' => 'text',
'label' => __( 'Project Name', 'my-plugin' ),
'ver Image', 'my-plugin' ),
'conditions' => array(
array( 'field' => 'is_featured', 'value' => true ),
),
),
),
)
);
$name = get_post_meta( $post_id, 'project_name', true );
$image = get_post_meta( $post_id, 'cover_image', true ); // Attachment ID.
'show_subtitle' => array(
'type' => 'toggle',
'label' => __( 'Show Subtitle', 'my-plugin' ),
),
'subtitle' => array(
'type' => 'text',
'label' => __( 'Subtitle', 'my-plugin' ),
'conditions' => array(
array( 'field' => 'show_subtitle', 'value' => true ),
),
),
wpify_custom_fields()->create_metabox(
array(
'id' => 'my_metabox',
'title' => __( 'Settings', 'my-plugin' ),
'tabs' => array(
'general' => __( 'General', 'my-plugin' ),
'advanced' => __( 'Advanced', 'my-plugin' ),
),
'items' => array(
'title' => array(
'type' => 'text',
'label' => __( 'Title', 'my-plugin' ),
'tab' => 'general',
),
'custom_css' => array(
'type' => 'code',
'label' => __( 'Custom CSS', 'my-plugin' ),
'language' => 'css',
'tab' => 'advanced',
),
),
)
);
$f = wpify_custom_fields()->field_factory;
wpify_custom_fields()->create_metabox(
array(
'id' => 'team_metabox',
'title' => __( 'Team', 'my-plugin' ),
'post_types' => array( 'page' ),
'items' => array(
'team_members' => $f->multi_group(
label: __( 'Team Members', 'my-plugin' ),
min: 1,
max: 20,
items: array(
'name' => $f->text( label: __( 'Name', 'my-plugin' ),