Loading scripts

This topic contains 1 reply, has 2 voices, and was last updated by  Stiofan O’Connor 10 years, 3 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket

Tagged: ,

  • Author
    Posts
  • #11384

    boxportable
    Buyer
    Post count: 42

    I have the following:

    
    
    
    
    function extra_scripts() {
        global $post_type;
        if( 'gd_place' == $post_type ) {
            
            wp_enqueue_media();
    
            // Registers and enqueues the required javascript.
            wp_register_script('extraimages_scripts', site_url().'/wp-content/plugins/geodirectory/geodirectory-assets/js/extraimages.js');
    
            wp_enqueue_script('extraimages_scripts');
        }
    }
    
    add_action('admin_enqueue_scripts', 'extra_scripts');
    

    As you can see this only loads on the default place type, is there a method of only loading scripts within geodirectory custom post types so I dont need to add the name of every post type I add?

    #11475

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Hello,

    Please use try this code(not tested) and let us know how u get on:

    
    
    function extra_scripts() {
        global $post_type;
    if(in_array( $post_type, geodir_get_posttypes() ) ){
            
            wp_enqueue_media();
    
            // Registers and enqueues the required javascript.
            wp_register_script('extraimages_scripts', site_url().'/wp-content/plugins/geodirectory/geodirectory-assets/js/extraimages.js');
    
            wp_enqueue_script('extraimages_scripts');
        }
    }
    
    add_action('admin_enqueue_scripts', 'extra_scripts');

    Thanks,

    Stiofan

Viewing 2 posts - 1 through 2 (of 2 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount