2 Formatting, tags
source | link

I know that manage_posts_custom_column, is used to add or remove custom columns to the custom post type page. The function kiran_custom_column_contentkiran_custom_column_content which is hooked to the function is called as a loop for all the posts on the page. Now I want to show the post numbers in serial under the number column. So, how can I do that? If it is a while loop, may be I could have set a variable to 0 and then increment it. But how can I set a variable outside the function and increment it each time the function is called. I have tried to declare a variable globally and then increment it inside the function. But it is not working.

add_action( 'manage_sponsor_posts_custom_column', 'kiran_custom_column_content', 10, 2 );

global $postNumber;
$postNumber = 1;

function kiran_custom_column_content( $column, $post_id ) {

    switch ( $column ){
        case 'number':
        echo $postNumber;
        break;

        case 'carousel':
        echo 'Carousel';    
        break;
    }
 $postNumber++;
}

I know that manage_posts_custom_column, is used to add or remove custom columns to the custom post type page. The function kiran_custom_column_content which is hooked to the function is called as a loop for all the posts on the page. Now I want to show the post numbers in serial under the number column. So, how can I do that? If it is a while loop, may be I could have set a variable to 0 and then increment it. But how can I set a variable outside the function and increment it each time the function is called. I have tried to declare a variable globally and then increment it inside the function. But it is not working.

add_action( 'manage_sponsor_posts_custom_column', 'kiran_custom_column_content', 10, 2 );

global $postNumber;
$postNumber = 1;

function kiran_custom_column_content( $column, $post_id ) {

    switch ( $column ){
        case 'number':
        echo $postNumber;
        break;

        case 'carousel':
        echo 'Carousel';    
        break;
    }
 $postNumber++;
}

I know that manage_posts_custom_column, is used to add or remove custom columns to the custom post type page. The function kiran_custom_column_content which is hooked to the function is called as a loop for all the posts on the page. Now I want to show the post numbers in serial under the number column. So, how can I do that? If it is a while loop, may be I could have set a variable to 0 and then increment it. But how can I set a variable outside the function and increment it each time the function is called. I have tried to declare a variable globally and then increment it inside the function. But it is not working.

add_action( 'manage_sponsor_posts_custom_column', 'kiran_custom_column_content', 10, 2 );

global $postNumber;
$postNumber = 1;

function kiran_custom_column_content( $column, $post_id ) {

    switch ( $column ){
        case 'number':
        echo $postNumber;
        break;

        case 'carousel':
        echo 'Carousel';    
        break;
    }
 $postNumber++;
}
1
source | link

manage_posts_custom_column, showing serial number using increment in loop

I know that manage_posts_custom_column, is used to add or remove custom columns to the custom post type page. The function kiran_custom_column_content which is hooked to the function is called as a loop for all the posts on the page. Now I want to show the post numbers in serial under the number column. So, how can I do that? If it is a while loop, may be I could have set a variable to 0 and then increment it. But how can I set a variable outside the function and increment it each time the function is called. I have tried to declare a variable globally and then increment it inside the function. But it is not working.

add_action( 'manage_sponsor_posts_custom_column', 'kiran_custom_column_content', 10, 2 );

global $postNumber;
$postNumber = 1;

function kiran_custom_column_content( $column, $post_id ) {

    switch ( $column ){
        case 'number':
        echo $postNumber;
        break;

        case 'carousel':
        echo 'Carousel';    
        break;
    }
 $postNumber++;
}