Tuesday 25 July 2017

change column position in wordpress








 add code on function.php

 //change manage_finance_posts_columns finance to your custom posttype

function array_insert( $array, $index, $insert ) {
    return array_slice( $array, 0, $index, true ) + $insert +
    array_slice( $array, $index, count( $array ) - $index, true);
}
add_filter('manage_finance_posts_columns', 'hs_finance_table_head');
function hs_finance_table_head( $columns ) {   

    return array_insert( $columns, 2,['country'=>'Country']);  

}

add_action( 'manage_finance_posts_custom_column', 'hs_finance_table_content');

function hs_finance_table_content( $column_name, $post_id ) {
   
    if( $column_name == 'country' ) {
       
                echo get_post_field('country', $post_id);       
    }

No comments:

Post a Comment