Crud Operation for Post / Post types
Want a successful Modern site?
Start with IQRA training; it’s easy and quick to your needs.
1. IQ_post_insert($array)
insert post data to database. function type return
Parametors
- array (array) (required)
// $array = array(
// 'title'=>'', required
// 'post_type'=>'', required
// 'permalink'=>'', optional
// 'content'=>'', optional
// 'status'=>'', optional
// 'layout'=>'', optional
// 'featured_img'=>'', optional
// 'author_id'=>,optional
// 'parent'=>,optional
// 'breadcrumb'=>,optional
// 'post_date'=>,optional
// 'modified_date'=>,optional
// 'status'=>,optional
// 'post_type'=>,optional
// 'layout'=>,optional
// 'post_excerpt'=>,optional
// 'comment_status'=>,optional
// 'ping_status'=>,optional
// 'post_password'=>,optional
// 'to_ping'=>,optional
// 'pinged'=>,optional
// 'post_content_filtered'=>,optional
// 'guid'=>,optional
// 'menu_order'=>,optional
// 'post_mime_type'=>,optional
// 'comment_count'=>,optional
// 'post_meta'=>array(array('meta'=>'value'),) or $array[] = [''=>''] or $meta = += [''=>''] options
// );
IQ_post_insert(array('title'=>'Hello', 'post_type' => 'services'));
2. IQ_post_update($array)
update post data to database. function type return
Parametors
- array (array) (required)
// $array = array(
// 'id'=>'', (required)
// 'title'=>'', optional
// 'post_type'=>'', optional
// 'permalink'=>'', optional
// 'content'=>'', optional
// 'status'=>'', optional
// 'layout'=>'', optional
// 'featured_img'=>'', optional
// 'post_meta'=>array(array('meta'=>'value'),) or $array[] = [''=>''] or $meta = += [''=>''] options
// );
IQ_post_update(array('title'=>'Hello', 'post_type' => 'services'));
3. get_post($data)
fetch post data to database. function type return.
parametors
- data (array) (required)
data
- 'post_type' or 'id' or 'query' (required)
- query (for custom query)
-
pagination (true / false) (optional)
- search (true / false) (optional)
- limit (fetch limit)
for pagination click here
get_post(array('id'=>'32', 'pagination' => 'true', 'limit'=>3));
4. get_post_meta($where)
fetch post meta data to database. function type return.
parametors
- where (string) (required)
where
- where (apply condition) (required)
get_post_meta('id'=>'3');
How to register custom View List
if(isset($_GET['post_type']) && $_GET['post_type'] === 'lottories'){
function lottories_data_change(){
global $fetch;
$newdata = [];
foreach($fetch as $data){
if($data['pinged'] == 1){
$data['pinged'] = 'Featured';
$newdata[] = $data;
}else{
$newdata[] = $data;
}
}
return $newdata;
}
add_filter('view_list_data_filter','lottories_data_change');
}
How to register custom View List button
function lottories_user_profile(){
global $fetchrows;
echo '<a class="btn btn-secondary" href="'.site_url('',$fetchrows['id']).'" target="_blank"><i class="ri-luggage-deposit-fill"></i></a> |';
}
add_action('view_user_list_btn_area','lottories_user_profile');