WordPress网站允许一个媒体文件关联附加到一篇文章,但是一般情况下是不能修改关联的,今天为大家分享一个为WordPress文件添加重新关联附加选项方法。
将下面代码添加到当前主题的 functions.php 文件:
add_filter(“**nage_upload_columns”, ‘upload_columns’);
add_action(“**nage_media_cus***_column”, ‘media_cus***_columns’, 0, 2);
function upload_columns($columns) {
unset($columns[‘parent’]);
$columns[‘better_parent’] = “Parent”;
return $columns;
}
function media_cus***_columns($column_n**e, $id) {
$post = get_post($id);
if($column_n**e != ‘better_parent’)
return;
if ( $post->post_parent > 0 ) {
if ( get_post($post->post_parent) ) {
$title =_draft_or_post_title($post->post_parent);
}
?>
<strong><a href=”https://www.wpzt.net/<?php echo get_edit_post_link( $post->post_parent ); ?>”><?php echo $title ?></a></strong>, <?php echo get_the_time(__(‘Y/m/d’)); ?>
<br />
<a class=”hide-if-no-js” onclick=”findPosts.open(‘media[]’,'<?php echo $post->ID ?>’);return false;” href=”#the-list”><?php _e(‘Re-Attach’); ?></a>
<?php
} else {
?>
<?php _e(‘(Unattached)’); ?><br />
<a class=”hide-if-no-js” onclick=”findPosts.open(‘media[]’,'<?php echo $post->ID ?>’);return false;” href=”#the-list”><?php _e(‘Attach’); ?></a>
<?php
}
}
暂无评论内容