Search
 
SCRIPT & CODE EXAMPLE
 

PHP

Add custom column at custom posts list

<?php
manage_{$post->post_type}_posts_custom_column
manage_{$post->post_type}_posts_columns
  
Here's an example how we could display a button, for each row in the send_email column:

/**
 * Books Post Table: Display a utton in each row in the 'send_email' column
 */
add_action( 'manage_books_posts_custom_column', function ( $column_name, $post_id ) 
{
    if ( $column_name == 'send_email')
        printf( '<input type="button" value="%s" />', esc_attr( __( 'Send Email' ) ) );

}, 10, 2 );

To add the send_email column we can use:

/**
 * Books Post Table: Add the 'send_email' column
 */
add_filter('manage_books_posts_columns', function ( $columns ) 
{
    if( is_array( $columns ) && ! isset( $columns['send_email'] ) )
        $columns['send_email'] = __( 'Send Email' );     
    return $columns;
} );
We could also limit the column width with:

/**
 * Limit the 'send_email' column width
 */
add_action( 'admin_print_styles-edit.php', function()
{        
    echo '<style> .column-send_email { width: 100px; }</style>';
} );
Comment

PREVIOUS NEXT
Code Example
Php :: wc php get currency symbol 
Php :: laravel seed table 
Php :: PHP strcspn — Find length of initial segment not matching mask 
Php :: howto+add+header+bar+laravel+app 
Php :: php get cosine sim 
Php :: PHP strspn — Finds the length of the initial segment of a string consisting entirely of characters contained within a given mask 
Php :: how to include pdf in php page 
Php :: PHP nl2br — Inserts HTML line breaks before all newlines in a string 
Php :: Unsupported type passed 
Php :: simple_html_dom stream does not support seeking 
Php :: php map array key to variable names 
Php :: how to access the name of menu in worpress 
Php :: how to keep some value on input field 
Php :: Do not call the observer when there is a model update in laravel 
Php :: command line that convert html to php file 
Php :: use varable on all site pages laravel 
Php :: how to override category product from seo title and description 
Php :: php endif endforeach endwhile 
Php :: where clause with paginate laravel multiple column 
Php :: symfony 6 download 64 bit 
Php :: split php 
Php :: heroku mysql 
Php :: create custom rule in laravel 
Php :: php pretty json 
Php :: Email "" does not comply with addr-spec of RFC 2822. 
Php :: Syntax error or access violation: 1055 
Php :: php izyboy 
Java :: java every second 
Java :: rgb to hex java 
Java :: how to set the java_home in mac 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =