• Resolved jasonday

    (@jasonday)


    I’m using a custom template for the single-listing.php.

    I’ve used my own theme (Canvas by woothemes) single post template, and included the wp-listings code. https://pastebin.com/cAYFEruA

    The issue I’m having is that my custom single-listing.php is in my child theme directory. Because of this the following code doesn’t work because the file paths are different:

    add_action('wp_enqueue_scripts', 'enqueue_single_listing_scripts');
    function enqueue_single_listing_scripts() {
    	wp_enqueue_style( 'wp-listings-single' );
    	wp_enqueue_style( 'font-awesome' );
    	wp_enqueue_script( 'jquery-validate', array('jquery'), true, true );
    	wp_enqueue_script( 'fitvids', array('jquery'), true, true );
    	wp_enqueue_script( 'wp-listings-single', array('jquery, jquery-ui-tabs', 'jquery-validate'), true, true );
    }

    None of these are loading in my custom template.

    What’s the best way to include them correctly?

    https://www.ads-software.com/plugins/wp-listings/

Viewing 1 replies (of 1 total)
  • Plugin Author agentevolution

    (@agentevolution)

    The scripts are registered by the plugin (in plugin.php) with the file path defined to the scripts in the plugin, so having your template in a child theme should make no difference. That function is just enqueuing those registered scripts.

    /** Registers and enqueues scripts for single listings */
    	add_action('wp_enqueue_scripts', 'add_wp_listings_scripts');
    	function add_wp_listings_scripts() {
    		wp_register_script( 'wp-listings-single', WP_LISTINGS_URL . 'includes/js/single-listing.js' ); // enqueued only on single listings
    		wp_register_script( 'jquery-validate', WP_LISTINGS_URL . 'includes/js/jquery.validate.min.js' ); // enqueued only on single listings
    		wp_register_script( 'fitvids', '//cdnjs.cloudflare.com/ajax/libs/fitvids/1.1.0/jquery.fitvids.js', array('jquery'), true, true ); // enqueued only on single listings
    		wp_enqueue_script( 'jquery' );
    		wp_enqueue_script( 'jquery-ui-tabs', array('jquery') );
        }

    You could try giving them the same path as the wp_register_script in the enqueue function.

Viewing 1 replies (of 1 total)
  • The topic ‘Adding single listing scripts/styles to custom template’ is closed to new replies.