I want to add the media uploader in the theme options page. If I add following code in the options page, the media uploader works fine there, but it creates problem in the standard posts featured image. It does not let me select any image from there.

Would it be because I'm adding it in wrong way?

if ( ! did_action( 'wp_enqueue_media' ) ){

Here's the uploading function I'm using:

    wp.media.editor.send.attachment = function(props, attachment){          
    return false;

1 Answer 1


There's not enough information to really determine what is happening, but the best course of action is to make sure your code is only added to the options page, so it can't interfere with anything on the edit page. You can use get_current_screen for that, like this:

add_action( 'current_screen', 'wpse113256_this_screen' );

function wpse113256_this_screen() {
    $current_screen = get_current_screen();
    if( $current_screen ->id === "options" ) {
        // Run your code

You'll have to check if the ID of your options page is actually "options".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.