您好,谢谢您,谢谢您能提供的任何帮助,
目前正在一个WordPress网站上同时运行砌筑,ImagesLoaded和Flickity,
如果我是对的,那么一切都在那里,我只是不明白为什么这些JQueries没有初始化?
(我当然是错的,因为代码不能)
如果您有心查看我的代码,请告诉我“哪里错了” 非常感谢 真诚的你的 “心烦意乱,难过的代码初学者”
****** Javascript
var $grid = jQuery('.grid').masonry( function() {
console.log("masonryinit: masonry");
$grid.masonry({
itemSelector: '.grid-item',
columnWidth: '.grid-sizer',
gutter: '.gutter',
percentPosition: true
});
});
var $grid = jQuery(".grid").imagesLoaded( function() {
console.log("imagesloadedinit: Images Loaded");
$grid.imagesloaded({
itemSelector: '.grid-item',
columnWidth: '.grid-sizer',
gutter: '.gutter',
percentPosition: true
});
});
var $main-carousel = jQuery(".main-carousel").flickity( function() {
console.log("flickityInit: flickity");
$main-carousel.flickity({
cellAlign: 'left',
contain: true
});
});
****** Functions.php
<?php
add_action( 'wp_enqueue_scripts', 'add_theme_scripts' );
function add_theme_scripts(){
global $ver;
wp_enqueue_script('app', get_template_directory_uri().'/javascript.js', array( 'jquery' ), $ver);
wp_enqueue_script('masonry', get_template_directory_uri().'/assets/masonry.js', array( 'jquery' ));
wp_enqueue_script('imagesloaded', get_template_directory_uri().'/assets/imagesloaded.js', array( 'jquery' ));
wp_enqueue_script('flickity', get_template_directory_uri().'/assets/flickity.js', array( 'jquery' ));
wp_enqueue_style('flickity', get_template_directory_uri().'/assets/flickity.css', array(), $ver);
wp_enqueue_style('app-style', get_template_directory_uri().'/style.css', array(), $ver);
}
add_action( 'init', 'wpb_custom_new_menu' );
function wpb_custom_new_menu() {
register_nav_menus(
array(
'my-custom-menu' => __( 'My Custom Menu' ),
'extra-menu' => __( 'Extra Menu' )
));
}
if( function_exists('acf_add_options_page') ) {
acf_add_options_page();
}
?>