
內容簡介
自版本 0.2.2 起,您可以選擇要在哪些文章類型中加入圖片列。
這只是在標題(最左邊)之前新增了一列,如果這個文章支援特色圖片並且已存在,它就會顯示。
想要更改預設圖片?只需使用 featured_image_column_default_image 過濾器過濾自己的圖片
或使用 featured_image_column_css 過濾器過濾自己的 CSS。
範例動作/過濾器
添加對自訂預設圖像的支援
function my_custom_featured_image_column_image( $image ) {
if ( !has_post_thumbnail() ) {
return trailingslashit( get_stylesheet_directory_uri() ) . 'images/featured-image.png';
}
return $image;
}
add_filter( 'featured_image_column_default_image', 'my_custom_featured_image_column_image' );
刪除對文章類型的支援,使用 featured_image_column_init 動作掛鉤作為過濾器。
function frosty_featured_image_column_init_func() {
add_filter( 'featured_image_column_post_types', 'frosty_featured_image_column_remove_post_types', 11 ); // Remove
}
add_action( 'featured_image_column_init', 'frosty_featured_image_column_init_func' );
function frosty_featured_image_column_remove_post_types( $post_types ) {
foreach( $post_types as $key => $post_type ) {
if ( 'post-type' === $post_type ) // 要刪除的文章類型。例如:'post' 或 'page'
unset( $post_types[$key] );
}
return $post_types;
}
添加您自己的 CSS 去更改圖像的尺寸。
/**
* @use '.featured-image.column-featured-image img {}'
*/
function my_custom_featured_image_css() {
return trailingslashit( get_stylesheet_directory_uri() ) . 'css/featured-image.css'; // 指向 CSS 的 URL
}
add_filter( 'featured_image_column_css', 'my_custom_featured_image_css' );
如有更多問題,請訪問http://austin.passy.co
外掛標籤
開發者團隊
原文外掛簡介
As of version 0.2.2 you can select which post types you’d like to have the image column.
It simply adds a column before the title (far left) the show’s the posts featured image if it’s supported and exists.
Want to change the default image? Simply filter you own image by using featured_image_column_default_image
or filter your own CSS by using the featured_image_column_css filter hook.
Example actions/filters
Add support for a custom default image
function my_custom_featured_image_column_image( $image ) {
if ( !has_post_thumbnail() ) {
return trailingslashit( get_stylesheet_directory_uri() ) . 'images/featured-image.png';
}
return $image;
}
add_filter( 'featured_image_column_default_image', 'my_custom_featured_image_column_image' );
Remove support for post types Use the featured_image_column_init action hook for your filter.
function frosty_featured_image_column_init_func() {
add_filter( 'featured_image_column_post_types', 'frosty_featured_image_column_remove_post_types', 11 ); // Remove
}
add_action( 'featured_image_column_init', 'frosty_featured_image_column_init_func' );
function frosty_featured_image_column_remove_post_types( $post_types ) {
foreach( $post_types as $key => $post_type ) {
if ( 'post-type' === $post_type ) // Post type you'd like removed. Ex: 'post' or 'page'
unset( $post_types[$key] );
}
return $post_types;
}
For more question please visit https://austin.passy.co
