3698 readers
( example screenshot )PHP
add_filter('manage_posts_columns', 'posts_columns_attachment_count', 5);
add_action('manage_posts_custom_column', 'posts_custom_columns_attachment_count', 5, 2);
function posts_columns_attachment_count($defaults){
$defaults['wps_post_attachments'] = __('Att');
return $defaults;
}
function posts_custom_columns_attachment_count($column_name, $id){
if($column_name === 'wps_post_attachments'){
$attachments = get_children(array('post_parent'=>$id));
$count = count($attachments);
if($count !=0){echo $count;}
}
}
Visit wpsnipp.com for details on how to setup this WordPress snippet. Share this post. Facebook | StumbleUpon |
9097 readers
PHP
add_filter('manage_media_columns', 'posts_columns_attachment_id', 1);
add_action('manage_media_custom_column', 'posts_custom_columns_attachment_id', 1, 2);
function posts_columns_attachment_id($defaults){
$defaults['wps_post_attachments_id'] = __('ID');
return $defaults;
}
function posts_custom_columns_attachment_id($column_name, $id){
if($column_name === 'wps_post_attachments_id'){
echo $id;
}
}
Visit wpsnipp.com for details on how to setup this WordPress snippet. Share this post. Facebook | StumbleUpon | Delicious | Tweet It | Digg This | DesignBump-It
4276 readers
Just a few updates to this including one courtesy of Cliff Paulick’s suggestion to check if post thumbnails are supportsed first to avoid errors. I also define a default image size and of course included both posts and pages in this snippet.( example screenshot )PHP
if (function_exists( 'add_theme_support' )){
add_filter('manage_posts_columns', 'posts_columns', 5);
6986 readers
PHP
function get_attachment_files(){
$args = array(
'post_type' => 'attachment',
'numberposts' => -1,
'post_status' => null,
'post_parent' => 0
);
$attachments = get_posts($args);
if ($attachments) {
foreach ($attachments as $post) {
setup_postdata($post);
8454 readers
( example screenshot )PHP
add_filter('manage_media_columns', 'posts_columns_attachment_exif', 1);
add_action('manage_media_custom_column', 'posts_custom_columns_attachment_exif', 1, 2);
function posts_columns_attachment_exif($defaults){
$defaults['wps_post_attachments_exif'] = __('EXIF');
return $defaults;
}
function posts_custom_columns_attachment_exif($column_name, $id){
if($column_name === 'wps_post_attachments_exif'){
$meta = wp_get_attachment_metadata($id);
if($meta[image_meta][camera] != ''){
echo
9354 readers
PHP
add_filter('manage_posts_columns', 'posts_columns_id', 5);
add_action('manage_posts_custom_column', 'posts_custom_id_columns', 5, 2);
add_filter('manage_pages_columns', 'posts_columns_id', 5);
add_action('manage_pages_custom_column', 'posts_custom_id_columns', 5, 2);
function posts_columns_id($defaults){
$defaults['wps_post_id'] = __('ID');
return $defaults;
}
function posts_custom_id_columns($column_name, $id){
if($column_name === 'wps_post_id'){
echo $id;
8710 readersIn a comment on my older post explaining how to integrate Facebook Like button into your WordPress theme, Mike was asking how to add the button into pages, instead of posts like I had explained. In that post I will propose a solution to solve that issue. The issue with the previous tutorial was with
6085 readers
( example screenshot )PHP
add_filter( 'manage_pages_columns', 'page_column_views' );
add_action( 'manage_pages_custom_column', 'page_custom_column_views', 5, 2 );
function page_column_views( $defaults )
{
$defaults['page-layout'] = __('Template');
return $defaults;
}
function page_custom_column_views( $column_name, $id )
{
if ( $column_name === 'page-layout' ) {
$set_template = get_post_meta( get_the_ID(), '_wp_page_template', true );
5567 readers
( Example screenshot )PHP
add_filter('media_upload_tabs','wpse13567_media_upload_tabs', 99);
function wpse13567_media_upload_tabs( $tabs ) {
if ( wpse13567_post_has_attachments() ) {
unset( $tabs['type'] );
}
unset( $tabs['type_url'] );
unset( $tabs['library'] );
return $tabs;
}
add_filter( 'media_upload_default_tab', 'wpse13567_media_upload_default_tab' );
function wpse13567_media_upload_default_tab( $tab ){
6699 readers
This snippet will do the job although it could use some tweaking that ill delve into in the future with an update. I found this much easier for clients to select images without going into the library and attaching images to posts.( example screenshot )PHP
add_action("admin_init", "images_init");
add_action('save_post', 'save_images_link');
function images_init(){
$post_types