X

Columnas de administración de la mediateca con ID de archivo adjunto

Snippets by IsItWP

La biblioteca multimedia tiene información específica sobre sus imágenes. Puede añadir otra columna para mostrar el ID del archivo adjunto con otros detalles.

Instrucciones: Añade el siguiente código al archivo functions.php de tu tema de WordPress.

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;
    }
}

También puede disfrutar de la eliminación de columnas multimedia.

Comentarios   Deja una respuesta

  1. Hi
    This worked thank you.
    I really need to see the ids and be able to sort/filter by image Ids when selecting an image or multiple images for a gallery slideshow.

    at present can only filter by date.

    any chance of a snippet to fix this please?

    Ps my problem is not knowing the question to ask google to find things – too hours to find this – so now have you book marked.

    1. This may or may not have everything you need, but you may want to check out this Stack Exchange entry: https://wordpress.stackexchange.com/questions/35680/sortable-custom-column-in-media-library

  2. Nice, thanks a lot!

  3. Eva Collados Pascual mayo 6, 2015 en 5:33 am

    Thanks Kevin! Worked perfectly for me. I tried other functions for this i’ve found on the web without you results.

    Addicted to your snippets!

  4. Thank you so much, you saved me hours and hours 😉

  5. Any way to make the column sortable in 3.5?

  6. Brandon Wilds mayo 1, 2012 en 11:45 am

    I am currently trying to get the attachment id to show in a custom field within my media library and cannot seem to figure out how to get it there.  Its easy to add to the media page itself using the $_REQUEST[‘attachment_id’] although this does not work in the media library.

    Your code above does not seem to work within my theme for whatever reason.

  7. This makes it MUCH easier to get the id. Would it be possible to add this column to the gallery tab on the media insert pop-over panel as well? (so you could easily see the id of an image for include or exclude in the shortcode)

    1. Hi David,
      I’m sure you could not something I have looked into, I do a little research for a future posting.

Añadir un comentario

Nos alegra que haya decidido dejar un comentario. Tenga en cuenta que todos los comentarios se moderan de acuerdo con nuestra política de privacidad , y que todos los enlaces son nofollow. NO utilice palabras clave en el campo del nombre. Tengamos una conversación personal y significativa.

WordPress Launch Checklist

La lista definitiva para lanzar WordPress

Hemos recopilado todos los elementos esenciales de la lista de comprobación para el lanzamiento de su próximo sitio web de WordPress en un práctico ebook.
Sí, envíeme el ¡gratuito!