Está procurando uma maneira de criar uma coluna de URL na Biblioteca de mídia? Este snippet criará uma nova coluna na Biblioteca de mídia com o URL do arquivo, o que permitirá que você copie e cole facilmente o URL.
Instruções:
Tudo o que você precisa fazer é adicionar esse código ao arquivo functions.php do seu tema ou em um plug-in específico do site:
function muc_column( $cols ) { $cols["media_url"] = "URL"; return $cols; } function muc_value( $column_name, $id ) { if ( $column_name == "media_url" ) echo '<input type="text" width="100%" onclick="jQuery(this).select();" value="'. wp_get_attachment_url( $id ). '" />'; } add_filter( 'manage_media_columns', 'muc_column' ); add_action( 'manage_media_custom_column', 'muc_value', 10, 2 );
Agradecemos a Steve Taylor pelo snippet original. Agradecemos a Jurko Chervony pelos ajustes sugeridos.
Observação: Se esta é a primeira vez que você adiciona trechos de código no WordPress, consulte nosso guia sobre como copiar/colar corretamente trechos de código no WordPress, para não danificar seu site acidentalmente.
Se você gostou desse snippet de código, considere dar uma olhada em nossos outros artigos no site, como: 27 melhores temas de negócios do WordPress para seu site e 15 melhores ferramentas e plugins de marketing de conteúdo para WordPress.
Wow, Thank you so much.
Awesome. I was looking for a plugin, but this is way easier and is now rolled into my child theme (and future child themes). Thanks!
Was looking all morning for something like this….Thanks
Works perfectly. Many thanks man!
[…] Source: http://wpsnipp.com/ […]
Thank you so much for sharing this. You just saved me a couple of hours and a bottle of Advil.
Thank you so much for sharing this. You just saved me a couple of hours and a bottle of Advil.
Thank you so much for sharing this. You just saved me a couple of hours and a bottle of Advil.
Thank you so much for sharing this. You just saved me a couple of hours and a bottle of Advil.
Thank you so much for sharing this. You just saved me a couple of hours and a bottle of Advil.
Thank you so much for sharing this. You just saved me a couple of hours and a bottle of Advil.
Thank you so much for sharing this. You just saved me a couple of hours and a bottle of Advil.
Thank you so much for sharing this. You just saved me a couple of hours and a bottle of Advil.
Thank you so much for sharing this. You just saved me a couple of hours and a bottle of Advil.
Thank you so much for sharing this. You just saved me a couple of hours and a bottle of Advil.
Thank you so much for sharing this. You just saved me a couple of hours and a bottle of Advil.
Thank you so much for this. Made a nifty little plugin for this!
Thank you so much for this. Made a nifty little plugin for this!
I copied and pasted it at the very bottom of the ‘functions.php’ file, and when I tried to open the website again, it gave me a fatal error. Any ideas why? I’m using wordpress 3.8.
Without taking a look at your functions.php I would not be sure what the issue was. You could put it on pastebin.com and use the contact form to send me the link so i can take a look at it.
http://wpsnipp.com/index.php/contact/
Hi Brent,
This may be good for some, just not sure its a great feature for everyone. Thanks for the feedback its great to hear what I’m posting is helping people.
man this is awesome! why this isn’t default in wordpress who knows. thanks a million!
Awesome! Thanks.
Thank you, thank you, thank you. I was going crazy with all the drilling down for urls. I really appreciate it!
So convenient. This should be a plugin… that gives me an idea!
oh maaaan you are the BOSSSS!!! Thanks!