Add the reassociation additional option for the WordPress media file

Source: Internet
Author: User
Tags php file

Add the following code to the functions. php file of the current topic:

The code is as follows: Copy code

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

Original article: http://zmingcx.com

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.