WordPress文件关联的重定向选择
WordPress主题站中的文章是可以被某个媒体文件进行关联附加的,只是不能够被选择性的修改关联重定向,那么就为大家介绍该如何文件关联附加选项的重定向设置:
将下面代码添加到当前主题的 functions.php 文件:
add_filter("manage_upload_columns", 'upload_columns');
add_action("manage_media_custom_column", 'media_custom_columns', 0, 2);
function upload_columns($columns) {
unset($columns['parent']);
$columns['better_parent'] = "Parent";
return $columns;
}
function media_custom_columns($column_name, $id) {
$post = get_post($id);
if($column_name != '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="<?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
}
}
0条评论