admin管理员组文章数量:1122846
I want to use attachment IDs for shortcodes, but if the image is published with a permalink, it's harder to find the ID.
I've found some functions online that can turn the attachment url into its ID, but that's ridiculous if I have to use a function every time I want to use the shortcode in my posts.
Trying to do: [stuff include="1,4,55"]
Instead of: [stuff include="..."]
I want to use attachment IDs for shortcodes, but if the image is published with a permalink, it's harder to find the ID.
I've found some functions online that can turn the attachment url into its ID, but that's ridiculous if I have to use a function every time I want to use the shortcode in my posts.
Trying to do: [stuff include="1,4,55"]
Instead of: [stuff include="http://www.example.com/wp-content/uploads/etc..."]
1 Answer
Reset to default 2You could hook into 'attachment_fields_to_edit'
and just add a row:
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: T5 Show Attachment ID
* Version: 2012.06.04
* Author: Fuxia Scholz
* License: MIT
* License URI: http://www.opensource.org/licenses/mit-license.php
*/
if ( ! function_exists( 't5_show_attachment_id' ) )
{
add_filter( 'attachment_fields_to_edit', 't5_show_attachment_id', 10, 2 );
function t5_show_attachment_id( $form_fields, $post )
{
$form_fields['t5_id'] = array (
'label' => 'ID',
'input' => 'html',
'html' => "<strong>$post->ID</strong>",
);
return $form_fields;
}
}
Result:
本文标签: permalinksIs there a way to show attachment IDs on the attachment info screen
版权声明:本文标题:permalinks - Is there a way to show attachment IDs on the attachment info screen? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736308200a1933576.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论