Warning: session_start(): open(/var/cpanel/php/sessions/ea-php74/sess_nbe0d58qms2a0uj0scl9ebvgvr, O_RDWR) failed: No such file or directory (2) in /home/mssoftpc/iqra.mssoftpc.com/admin/function.php on line 3

Warning: session_start(): Failed to read session data: files (path: /var/cpanel/php/sessions/ea-php74) in /home/mssoftpc/iqra.mssoftpc.com/admin/function.php on line 3
Crud Operation for Post / Post types | IQRA CMS

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

  1. 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

  1. 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
 
  1. data (array) (required)

 

data

  1. 'post_type' or 'id' or 'query' (required)
  2. query (for custom query)
  3. pagination (true / false) (optional)
  4. search (true / false) (optional)
  5. 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
  1. where (string) (required)

 

where

  1. 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');