• Hi,

    I am customizing my new own theme which is using function.php to implement custom fields for posts write panel. Some of my field for example and Image upload field needs the option to clone the field in order to make the user upload many images and store the links in custom field records.
    To do this I need to enable Jquery inside the admin (wp-admin/post-new.php) page and have gone several hours searching for a solution through the forum and documents.

    I was able to implement is using the following technique inside my theme function.php file, however I know that is not the right way to do it.

    if (is_admin()){
    function loadjquery(){?>
        <script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/jquery-1.4.1.min.js"></script>
    <?php
    } 
    
    add_action("admin_head","loadjquery");
    ?>

    I did try using the function wp_enqueue_script('jquery');
    but the admin page header did not load jquery to it.

    Can any one of you please tell how to make it possible. What I am trying to do here is use a Jquery plugin called relCopy inside add new post page in admin section.

Viewing 1 replies (of 1 total)
  • Did you have any success? I am trying to use:

    <?php
    	function my_admin_scripts() { // function to load scripts
    	wp_enqueue_script('media-upload');
    	wp_enqueue_script('thickbox');
    	wp_register_script('my-upload', WP_PLUGIN_URL.'/my-script.js', array('jquery','media-upload','thickbox'));
    	wp_enqueue_script('my-upload');
    	}
    
    	function my_admin_styles() {
    	wp_enqueue_style('thickbox');
    	}
    
    	if (isset($_GET['page']) && $_GET['page'] == 'my_plugin_page') {
    	add_action('admin_print_scripts', 'my_admin_scripts'); // load own javascripts
    	add_action('admin_print_styles', 'my_admin_styles'); // load own css
    	}
    
    	?>
    		<tr valign="top">
    		<th scope="row">Upload Image</th>
    		<td><label for="upload_image">
    		<input id="upload_image" type="text" size="36" name="upload_image" value="" />
    		<input id="upload_image_button" class="thickbox" type="button" value="Upload Image" />
    		<br />Enter an URL or upload an image for the banner.
    		</label></td>
    		</tr>

    To load scripts and activate an image uploader in the backend, but I have been unsuccessful so far..

Viewing 1 replies (of 1 total)
  • The topic ‘Can I be able to load JQUERY inside wp-admin/post-new.php’ is closed to new replies.