Tag: wordpress

WordPress下拉菜单点击打开

我正在尝试创建一个单击时打开的wordpress下拉菜单。 当你选择一个post并且页面加载该post时它应该保持打开状态。 问题是我正在使用自定义菜单项链接,它链接到任何内容(“#”)只是为了使它们可以点击。 单击“可点击的第二级标题项”时菜单打开,但“第三级post”上的链接不起作用,而是单击它时菜单关闭。 HTML: Main menu title item Post 1st lvl Post 1st lvl Post 1st lvl Post 1st lvl Clickable 2nd level title item Post 3rd lvl Post 3rd lvl Post 3rd lvl jQuery的: $(‘#menu-header ul.sub-menu li.second:not(“.third”)’).toggle(function() { $(this).find(‘ul.sub-menu:first-of-type’) .stop(true, true).delay(50).show(“slow”); }, function(){ $(this).find(‘ul.sub-menu:first-of-type’) .stop(true, true).delay(150).animate({ “height”: “hide”, “opacity”: “hide” }, 400 ); […]

conflit jquery wordpress bootstrap

我正在使用bootstrap到WordPress主题,我在wp-include文件夹中的jQuery和我的主题jQuery之间存在冲突 这是我需要bootstrap.min.js和jquery.js的函数jQuery jQuery(function($) {‘use strict’, //#main-slider $(function(){ $(‘#main-slider.carousel’).carousel({ interval: 8000 }); }); }); 我怎么能解决这个问题?

在wordpress中调用js文件

我有一个wordpress网站,我正在尝试加载.js文件。 出于某种原因,我无法让它发挥作用。 js文件位于http://www.leadcomm.net/pricequotejs.js 我把它放在页脚中: if (window.location.href == ‘http://www.leadcomm.net/cost-estimate/’) { var js = document.createElement(‘script’); js.setAttribute(“type”,”text/javascript”); js.setAttribute(“src”, “pricequotejs.js”); document.getElementsByTagName(“head”)[0].appendChild(js); } 关于我做错的任何想法?

Woocommerce – AJAX添加到购物车不存储产品元数据

我已成功在WooCommerce上实现了AJAX添加到购物车function,适用于单一和可变产品。 尝试将自定义产品数据添加到购物车时出现问题,例如“产品交付日期”插件,该插件将日期选择器框添加到产品单页,允许用户选择产品的交货日期。 此数据未添加到购物车。 我已经使用Storefront主题进行了测试,并且产品元数据存储在购物车中,所以我确定它与我传递给AJAX函数的变量有关。 我的AJAX知识是基本的,所以如果我遗漏了一些明显的东西,请原谅我。 JS用于添加到购物车: jQuery(document).ready(function() { jQuery(‘.single_add_to_cart_button’).click(function(e) { e.preventDefault(); jQuery(this).addClass(‘adding-cart’); var product_id = jQuery(this).val(); var variation_id = jQuery(‘input[name=”variation_id”]’).val(); var quantity = jQuery(‘select[name=”quantity”]’).val(); console.log(quantity); jQuery(‘.cart-dropdown-inner’).empty(); if (variation_id != ”) { jQuery.ajax ({ url: crispshop_ajax_object.ajax_url, type:’POST’, data:’action=crispshop_add_cart_single&product_id=’ + product_id + ‘&variation_id=’ + variation_id + ‘&quantity=’ + quantity, success:function(results) { jQuery(‘.cart-dropdown-inner’).append(results); var cartcount = jQuery(‘.item-count’).html(); jQuery(‘.cart-totals’).html(cartcount); […]

使用JSON显示来自多个facebook Feed的post

我想为WordPress网站创建一个脚本(javascript / jQuery),允许我从多个Facebook页面获得最新post。 我不希望post按帐户排序,但要混合在一起,按created_time排序。 我已经搜索了插件,我不想要一个WP插件。 FaceBook Posts function fbFetch(){ //Set Url of JSON data from the facebook graph api. make sure callback is set with a ‘?’ to overcome the cross domain problems with JSON var url = “https://graph.facebook.com/footengo31/posts?access_token=XXX&limit=5&callback=?”; var url2 = “https://graph.facebook.com/footengo01/posts?access_token=XXX&limit=5&callback=?”; var url3 = “https://graph.facebook.com/Footengo69/posts?access_token=XXX&limit=5&callback=?”; $.getJSON(url,function(json1){ $.getJSON(url2,function(json2){ $.getJSON(url3,function(json3){ var json = {}; json[‘json1’] […]

bootstrap模态显示与cookie设置为1天

我在Wordpress网站上有一个bootstrap模式,我希望每24小时只出现一次。 我以为我拥有它,但这不起作用。 $(document).ready(function() { if ($.cookie(‘show’) == null) { $(‘#myModal’).modal(‘show’); $.cookie(‘show’, { expires: 1 }); } }); 这只显示一次,然后再次显示。 我哪里错了?

WordPress,jquery加载php文件未找到

我正在通过jquery / ajax将php文件动态加载到Wordpress页面模板中。 我有以下工作在本地服务器上,但当我上传到我的测试网站时,我在加载文件时在控制台中出现404错误。 汇总代码: var root = location.protocol + ‘//’ + location.host; $(“.button-book”).click(function(e) { e.preventDefault(); $(‘#container’).load(root+’/wp-content/themes/PL14-Base/inc/bookings-swiss.php’); }); 你可以在这里看到开发网站。 点击第一个“预订”按钮查看问题。 更新:为了清楚起见,我已经更改了代码以使用确切的URL。直接在浏览器中调用时,可以在正确的URL找到该文件。

WordPress:删除特定页面的元标记

我想从WordPress网站上的特定页面中删除以下元标记: 这是为了禁用移动设备上的默认缩放,我发现以下function可以做到这一点: 不太确定如何应用它,必须删除元标记的页面名称称为“计划” 任何帮助,将不胜感激

将PHP函数连接到AJAX请求:我缺少什么?

回调消息为0,我无法弄清楚原因。 我试图尽可能地遵循本教程 ,但我显然错过了一些东西。 在Google Chrome上的网络中,每次单击触发表单提交的按钮时,我都会看到正在调用admin-ajax.php且状态为200。 我究竟做错了什么? error_reporting(-1); ini_set(‘display_errors’, ‘On’); $tm = new TeamManager(); add_action(‘wp_ajax_member-update’, ‘member_update’); function member_update() { echo json_encode(“TEST … “); } jQuery(‘.member-update-button’).click(function () { var parentForm = jQuery(this).closest(‘form’); var postData = parentForm.serializeArray(); jQuery.ajax({ url: “”, data: { action: ‘member_update’, postData: postData }, type: “POST”, dataType: ‘json’, success: function (retmsg) { alert(retmsg); // test […]

jQuery Knob Release函数附加参数

我正在使用jQuery Knob插件https://github.com/aterrien/jQuery-Knob 现在,我有以下jQuery旋钮初始化 loop <input type="text" value="” class=”circle-rating” data-entryid=””> endloop $(function() { $(“.circle-rating”).knob({ ‘min’:0, ‘max’:10, ‘step’:1, ‘width’:40, ‘height’:40, ‘fgColor’:”#F59B00″, ‘inputColor’:”#F59B00″, ‘displayPrevious’: true, ‘release’ : function (v) { var entry_id = $(this).attr(‘data-entryid’); jQuery.post(“/path/to/file/update_library_score.php”, {v : v, entry_id : entry_id}, function(data) { console.log(entry_id); jQuery(‘#notification-general’).html(entry_id); }); } }); }); 主要问题是我在页面上有多个旋钮。 这些旋钮实际上是一个带有wordpresspost的循环。 无论如何,每个旋钮都附加到一个ID ,当你通过循环时,这个ID发生变化。 现在为了能够更新分数,我需要两个东西,即从release函数获得的旋钮value ,我还需要post_id ,我只能在循环内获得。 那么如何才能将post_id变量赋予此函数? 通常我只需添加一个button或带有onclick=”my_function()但是,我不能用这个来做。抓住与你对应的$ […]