shshanker
11/15/2015 - 11:44 AM

Adding Requested Offer Id infront of the title

Adding Requested Offer Id infront of the title

<?php

// Adding Requested Offer Id infront of the title
function gs_requested_offer_add_id_column( $columns ) {
  
  $checkbox = array_slice( $columns , 0, 1 );
  $columns = array_slice( $columns , 1 );

  $id['requested_offer_id'] = 'ID'; 
  
  $columns = array_merge( $checkbox, $id, $columns );
  return $columns;



  /* $columns['requested_offer_id'] = 'ID';
   return $columns;*/
}

function gs_requested_offer_id_column_content( $column, $id ) {
  if( 'requested_offer_id' == $column ) {
    echo $id;
  }
}
add_filter( 'manage_requested_offer_posts_columns', 'gs_requested_offer_add_id_column', 5 );
add_action( 'manage_requested_offer_posts_custom_column', 'gs_requested_offer_id_column_content', 5, 2 );

// make sortable
function my_sortable_cake_column( $columns ) {
    $columns['requested_offer_id'] = 'ID';
 
    //To make a column 'un-sortable' remove it from the array
    //unset($columns['date']);
 
    return $columns;
}

add_filter( 'manage_edit-requested_offer_sortable_columns', 'my_sortable_cake_column' );

// make sortable with metavalues
add_action( 'pre_get_posts', 'my_slice_orderby' );
function my_slice_orderby( $query ) {
    if( ! is_admin() )
        return;
 
    $orderby = $query->get( 'orderby');
 
    if( 'slice' == $orderby ) {
        $query->set('meta_key','slices');
        $query->set('orderby','meta_value_num');
    }
}



?>