How to Add custom Field in View / Content Pages
Want a successful Modern site?
Start with IQRA training; it’s easy and quick to your needs.
How to Add custom Field in View / Content Pages
There are 2 seprate part in view page
- New / Edit
- View List (view all pages)
Global Variables
-
fetchrows (get data)
- meta_array (get meta data)
Global Database Variables
-
result (get all result)
-
arry (get meta data)
Global Add Action
-
admin_dashboard_breadcrumb
-
admin_action_fields
-
admin_action_tab
-
admin_action_sidebar_tab
Database Add Action
-
before_post_submit
-
before_post_meta_insert_action
-
post_insert_action
-
before_post_meta_update_action
-
post_update_action
Notice Add Action
-
success_post_list_notice
-
error_post_notice
-
success_post_notice
-
post_list
1. post_type_function_exec($post_type,$function)
parametors
- post type (required)
- function (required) (calling function)
function post_type_custom(){
function hello(){
// enter code here
}
post_type_function_exec('page' , 'hello');
}
add_action('admin_action_fields' , 'post_type_custom');
parametors
- data (required)
data
- title (required)
- header_btn (optional)
- function name (required)
function tab_function(){
// write code here
}
IQ_dashboard_widget(array('title'=>'Page Settings', 'View All', 'tab_function'))
How to add IQ dashboard widget in post type
function post_type_custom(){
function hello(){
function tab_function(){
// write code here
}
IQ_dashboard_widget(array('title'=>'Page Settings', 'View All', 'tab_function'))
}
post_type_function_exec('page' , 'hello');
}
add_action('admin_action_fields' , 'post_type_custom');
3. get_field($data)
parametors
- data (required) (array)
data
- title
- label (Default Value: True (Value: True, False) (title show or hide)
- name (form name)
- type (Default Value: text) (Values: text,textarea, select, reset, file, range, checkbox, textarea, week, select )
- id (field id)
- value (field value)
- class (field class)
- required (true, false)
- field_class
- field_id
- placeholder
- extra_input_data (for extra attributes)
- isset (array) (used for data exist )
- post_type
- value
- min
- max
- options
-
multiple
-
img_url
function post_type_custom(){
get_field(array('title'=>'Short description', 'name'=>'short_disc')) ;
// Hide Title
get_field(array('label'=>false, 'name'=>'short_disc')) ;
}
function post_type_custom(){
// used with post type (this function will execute only on post_type=page)
get_field(array('title'=>'Short description', 'name'=>'short_disc','post_type'=>'page')) ;
}
add_action('admin_action_fields' , 'post_type_custom');
Type: button submit / reset button / button
// type: submit
// type: reset
// type: button
get_field(array('title'=>'Short description', 'name'=>'short_disc', 'type'=>'submit')) ;
Type: text / tel / email / url / password / number / checkbox / radio / textarea / week
get_field(array('title'=>'Short description', 'name'=>'short_disc', 'type'=>'submit', 'placeholder'=>'Short Description')) ;
Type: range
get_field(array('title'=>'Age', 'name'=>'age', 'type'=>'range', 'max'=>'12', 'min'=>'30')) ;
Type: Extra Attribute
get_field(array('title'=>'Short description', 'name'=>'short_disc', 'type'=>'email', 'extra_input_data'=>'disable')) ;
Type: Select
$options = array(
array('value','key','attributes')
);
get_field(array('title'=>'Select Category', 'name'=>'categories', 'type'=>'select', 'options'=>$options)) ;
How to use this get_field() function in form when data exist.
$options = array(
array('value','key','attributes')
);
or
$options[] = ['right','Right'];
$options[] = ['left','Left'];
get_field(array('title'=>'Select Category', 'name'=>'categories', 'type'=>'select', 'options'=>$options, 'isset'=> $meta_array)) ;
- admin_view_fields($title, $name, $post_type);
$name (form or mysqli name)
admin_view_fields('Payment Status', 'payment_status', 'lottories-orders');