Tag: wordpress

自动启用虚拟和可下载的产品设置

使用WooCommerce,我使用的是供应商插件,允许人们上传自己的产品。 但是我只希望他们上传虚拟和可下载的产品。 有没有办法在正常的woocommerce“添加产品页面”中删除(甚至隐藏)这些选项并自动检查它们? 在调整所有提交内容时,不需要无法规避 – 只是想让提交过程尽可能简单。 谢谢

未捕获的ReferenceError:未定义jQuery

我正在尝试将一个带有JQuery滑块插件的Wordpress网站放在一起,但插件没有显示在页面上,我总是得到上面的错误消息。 尽管在其他post中尝试了几种不同的修复方法,我仍然无法解决上述错误,包括将脚本标记放在“header.php”文件中。 任何帮助将不胜感激 – 谢谢! ‘footer.php’文件中的相关代码 网站: http://www.advanceprojects.com.au/ : http://www.advanceprojects.com.au/

WordPress:单页滚动JQuery脚本无法正常工作?

试图创建一个简单的单页滚动。 在WordPress中,我有导航这样的标签。 Contact About 两个链接的对应div是这个。 #content #content </div 这是问题(我认为)。 我的脚本没有选择锚链接ID。 的script.js /* ONE PAGE NAVIGATION FUNCTION */ function setBindings() { jQuery(‘a[href^=”#”]’).click(function(e) { // prevent anchor tags for working (?) e.preventDefault(); var sectionID = e.currentTarget.id + “-View”; jQuery(“html, body”).animate({ scrollTop: jQuery(“#” + sectionID).offset().top }, 1000) }) } 任何想法,我在这里做错了什么? 这是网站 更新 **以下是我在查看答案后所做的修改。 脚本仍然不起作用?! jQuery(document).ready(function() { // add […]

根据选择器选择显示自定义结帐字段

基于这个工作答案: 自定义下拉选择器显示或隐藏其他Checkout自定义字段 在WooCommerce结帐页面中,我使用下面的代码创建一些其他自定义字段并重新排序所有结帐字段。 我使用jQuery脚本根据选择器选项显示/隐藏一些字段。 这是我的新代码: // Registering external jQuery/JS file function cfields_scripts() { /* IMPORTANT NOTE: For a child theme replace get_template_directory_uri() by get_stylesheet_directory_uri() The external cfields.js file goes in a subfolder “js” of your active child theme or theme.*/ wp_enqueue_script( ‘checkout_script’, get_template_directory_uri().’/js/cfields.js’, array(‘jquery’), ‘1.0’, true ); } add_action( ‘wp_enqueue_scripts’, ‘cfields_scripts’ ); add_filter( ‘woocommerce_checkout_fields’, ‘custom_checkout_billing_fields’ […]

强制特定版本jquery – WordPress

我一直试图强迫我的wordpress网站使用特定版本的jquery。 自从wordpress上次更新后,用户必须使用版本1.9,因此我的菜单栏现在无法正常工作。 直到我从此升级中找到修复程序,我想强制我的网站使用以前版本的jquery。 为此,我已经尝试了两件事: 我编辑了functions.php文件以添加一些代码。 我从这个链接得到了这个:( http://www.wpbeginner.com/wp-themes/replace-default-wordpress-jquery-script-with-google-library/ ) //Making jQuery Google API function modify_jquery() { if (!is_admin()) { // comment out the next two lines to load the local copy of jQuery wp_deregister_script(‘jquery’); wp_register_script(‘jquery’, ‘http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js’, false, ‘1.8.1’); wp_enqueue_script(‘jquery’); } } add_action(‘init’, ‘modify_jquery’); 我编辑了default-options.php文件,并在其中说’jquery’=> true,我将其更改为false。 但是,这些选项都没有奏效,我的网站仍然加载了jquery的1.9.1版本。 该网站的链接是www.fiestacolegial.com 请让我知道我可以做些什么来强制以前版本的jquery或其他调整来修复子菜单没有加载。 谢谢!

如何在使用jQuery在页眉和页脚之间滚动时使侧边栏变粘(不滚动它们)?

我需要一个严格的jQuery解决方案来解决这个问题。 这是因为我正在使用Wordpress,而我想制作粘贴的侧边栏小部件位于 元素内部,我无法完全达到高度。 就像.scrollTop()检测页面向下走多远使侧边栏小部件变粘的方式一样,我需要JS检测我从页面底部到底是多远,通过指定一个新的固定位置来“取消”小部件。 我尝试使用.offset()进行此操作,但到目前为止我还无法使其工作。 function stopDiv() { var distance = $(‘.footer’).offset().top – $(‘.widget’).offset().top; if (distance < 10) { $('.widget').css({ 'top': 'auto', 'bottom': '10px' }); } } 你可以在我的侧栏下方的片段中看到它应该滚动,但我希望侧边栏在距离页脚距离<10px时采用新的固定位置。 我希望侧边栏在页脚上方采用新的固定位置,直到用户向上滚动。 编辑: @Benvc下面建议的解决方案在片段中工作正常,但在我的wordpress网站上没有。 以下是我得到的控制台错误: scripts.js:18 Uncaught ReferenceError: s is not defined at HTMLDocument. (scripts.js:18) at i (jquery.js:2) at Object.fireWith [as resolveWith] (jquery.js:2) at Function.ready (jquery.js:2) at HTMLDocument.K […]

Ajax标签(wordpress)

所以,我是Ajax的新手,在阅读了一些在线教程之后,下面就是我所理解的。 如果我错了,请纠正我。 现在的情况: Tab_menu.php:默认情况下,在页面加载中显示Tab 1选项卡。 对于Tab 2选项卡, menu_tab2.php内容显示在页面加载上。 Tab 1 Tab 2 Tab 3 Tab 4 Tab 5 Tab 1 Content menu_tab2.php(以及其他选项卡的类似内容) Tab 2 content 所以,我想使用ajax将选项卡php文件内容加载到相应的选项卡中。 这是我到目前为止( 仅在单击时执行php函数(wordpress) ) jQuery的 $(document).ready(function() { $(‘.my_tabs a’).click(function(e) { e.preventDefault(); var tab_id = $(‘this’).attr(‘id’); $.ajax({ type: “GET”, url: “wp-admin/admin-ajax.php”, dataType: ‘html’, data: ({ action: ‘my_tab_menu’, id: tab_id}), success: function(data){ […]

AJAX提交和500服务器错误

尝试运行我的AJAX时出现500服务器错误。 我是AJAX的新手。 如果我在脚本中没有运行AJAX,那么每个东西都在代码中运行,例如只运行: $(“#book-appointment-form”).submit(); 因此,似乎所有数据库function都很好。 但是,我需要AJAX在Wordpress页面中运行我的代码。 我没有在错误日志中看到任何注释。 控制台日志显示该URL指向正确的位置。 我可能缺少什么? 控制台日志显示hiddenData中显示的隐藏输入中的数据: 0: Object name: “csrfToken” value: “0f4343dfd0e71a8fa515d08f340f7bc9” __proto__: Object 1: Object name: “post_data” value: “{“customer”:{“last_name”:”Test”,”first_name”:”Joe”,”email”:”email4me@verizon.net”,”phone_number”:”9093334444″,”address”:””,”city”:””,”zip_code”:””,”id_cellcarrier”:”2″,”wp_id”:”1″},”appointment”:{“start_datetime”:”2015-12-25 11:00:00″,”end_datetime”:”2015-12-25 11:50:00″,”notes”:””,”is_unavailable”:false,”id_users_provider”:”85″,”id_services”:”13″},”manage_mode”:false}” __proto__: Object length: 2 __proto__: Array[0] 视图: Confirm JS $(“#book-appointment-form”).submit(function(event){ var confirmedData = $(this).serializeArray(); var dataUrl = GlobalVariables.baseUrl + ‘/index.php/appointments/ajax_confirm_appointment’; $.post(dataUrl, confirmedData, function(response) { //////////////////////////////////////////////////////////// console.log(‘Customer Confirmed Post Response:’, […]

如何通过jquery从数据库接收数据?

我想在wordpress主题的.js文件中从数据库中获取少量数据。 我尝试使用jquery的.post()但没有发生任何事情。 还请建议我任何候补。 .js文件中的代码 jq.post(“../abc.php”, { name:”kumar”, accId:window.accommodationId }, function(data,status) { alert(“hello”); //alert(“Data: ” + data + “\nStatus: ” + status); } ); abc.php文件中的代码 get_results( “SELECT price_per_day FROM wp_byt_accommodation_vacancies where accommodation_id=’1741′” ); echo $max_minAge[0]->price_per_day; ?>

TypeError:$在jquery中未定义

我正在尝试在基于Wordpress的网站上使用jquery中的“tabcordion”库。 tabcordion javascript文件正在“排队”并出现在jquery文件之后(因此该位看起来没问题)。 jquery代码的开头是: (function($) { var Tabcordion; $.fn.tabcordion = function(option) { return this.each(function() { var $this, data, options; $this = $(this); // rest of code …. 当我加载我的页面时,我在Firebug中收到错误“TypeError:$ is undefined” 经过一番谷歌搜索,我改变了所有的$。 进入jQuery。 这解决了一些问题,但我得到关于该行的错误: $this = $(this); 我假设我没有为jquery定义$。 我尝试在函数顶部添加一行: $ = jQuery; 但那没用。 任何想法如何让我的行为? 我有另一个脚本,包含在: (function($){ jQuery(document).ready(function($){ // code in here }); })(jQuery); 但是tabcordion的结尾有: (function($) { […]