Tag: wordpress

为什么我的ajax请求得到响应0?

我在我的wp主题中设置了基本的wordpress ajax示例。 触发器由modernizr.js检查页面上的媒体查询。 jQuery(document).ready(function($) { if(Modernizr.mq(‘only all and (max-width:6300px)’)) { var data = { action: ‘my_action’, whatever: ajax_object.we_value // We pass php values differently! }; // We can also pass the url value separately from ajaxurl for front end AJAX implementations jQuery.post(ajax_object.ajax_url, data, function(data) { $(“#trending-Container”).html(data).fadeIn(1000); }); } });//end function 我已经对我的脚本进行了本地化和排队。 wp_enqueue_script(‘mainJS’, get_template_directory_uri() . ‘/js/mainJS.js’, […]

jQuery.browser:Javascript Uncaught TypeError

我遇到了一个错误,它不会让我的页面加载。 未捕获的TypeError:无法读取未定义的属性“msie” 控制台中的错误引用此代码: if (jQuery.browser.msie) extra_px += 3; // Fix Link Clicking on IE 7 and below versions if (jQuery.browser.msie && Number($.browser.version) < 8) { span_text.css('cursor', 'pointer'); span_text.click(function() { window.location = menu_item.parent().attr("href"); }); } 奇怪的是它突然发生了,我没有改变一件事。 作为参考,我正在使用Wordpress。

WordPress – 如何通过AJAX获取更多post?

首先,我认为这是一个远景,但希望有人可以提供帮助。 为了解释目前的情况,目前我有一个自定义插件,可以获取有关用户及其最近4个post的各种信息。 我也在使用WPBook插件(所以这是在Facebook上,只是一个典型的wordpress网站) 好的,所以这里是我的代码,它抓住了用户的4个最新post: // The Query query_posts(‘posts_per_page=4&author=’.$blogger_id); // set $more to 0 in order to only get the first part of the post global $more; $more = 0; // the Loop while (have_posts()) : the_post(); ?> <a href="https://stackoverflow.com/questions/11887760/wordpress-how-can-i-fetch-more-posts-via-ajax/” <a href="https://stackoverflow.com/questions/11887760/wordpress-how-can-i-fetch-more-posts-via-ajax/”> <span class="”> Load More 我尝试按照本教程,但不是单独的插件,将代码放在我现有的插件中,但现在我的页面将无法加载: Load Next WordPress Posts With AJAX 理想情况下,我想要的是当点击加载更多按钮时,再获取4个post并显示它们。 如果有人可以提供帮助,我会非常感激。 UPDATE […]

简单的WordPress AJAX分页

我正在使用下面的循环+ jQuery加载下一组页面,它在第一次单击时工作,但是当下载页面加载并点击“更新的post”时,它会重新加载整个页面。 有任何想法吗? query(‘post_type=post&showposts=1′.’&paged=’.$paged); ?> have_posts()) : $new_query->the_post(); ?> max_num_pages) ?> $(‘#pagination a’).on(‘click’, function(event){ event.preventDefault(); var link = $(this).attr(‘href’); //Get the href attribute $(‘#content’).fadeOut(500, function(){ });//fade out the content area $(‘#content’).load(link + ‘ #content’, function() { }); $(‘#content’).fadeIn(500, function(){ });//fade in the content area });

Flex Slider – 如何为两个滑块添加相同的控件

我正在使用Flex slide r进行一个项目。 我需要在一个页面上使用相同的控件控制两个滑块。 一部分是显示图像的主滑块,第二部分是文本(在这种情况下,它将取自WP中的“the_excerpt”)。 基本上,这是我用来在一个页面上调用两张幻灯片的代码: $(window).load(function() { $(‘#main-slider’).flexslider({ animation: ‘slide’, controlsContainer: ‘.flex-container’ }); $(‘#secondary-slider’).flexslider(); }); 现在,我需要将它们“连接”到相同的控件,所以当我点击箭头时,它会滑动/淡化它们。

woocommerce自定义结帐字段添加费用订购ajax

我试图在结账时向订单总额支付定制费用。 我在woocommerce中添加了一个复选框 add_action( ‘woocommerce_after_checkout_billing_form’, ‘add_box_option_to_checkout’ ); function add_box_option_to_checkout( $checkout ) { echo ”; woocommerce_form_field( ‘add_gift_box’, array( ‘type’ => ‘checkbox’, ‘class’ => array(‘add_gift_box form-row-wide’), ‘label’ => __(‘Ilość pudełek ozdobnych – 25 PLN/szt’), ‘placeholder’ => __(”), ), $checkout->get_value( ‘add_gift_box’ )); } 包含一个可以处理事件的自定义js文件 jQuery( document ).ready(function( $ ) { $(‘#add_gift_box’).click(function(){ var data = { action: ‘woocommerce_add_gift_box’, state: ‘200’, […]

在JSON API WordPress上启用CORS

我有一个带有一个名为JSON API的插件的wordpress网站。 此插件为wordpress中的内容提供JSON格式。 我能够通过添加标题(“Access-Control-Allow-Origin:*”)在wordpress上启用CORS; 在PHP标题上。 但是当我尝试使用JSON API插件提供的URL时,CORS不再起作用了。 这是wordpress网站,我正在做测试…我使用测试cors网站检查它是否正常工作,它是… http://kiwa-app.loading.net/ 但是,当我尝试使用JSON api为我提供的URL时,不再工作了。 我仍然有错误No’Access-Control-Allow-Origin’http: //kiwa-app.loading.net/?json=info 我会感谢一些帮助!

如何使用Ajax onclick加载WordPress Post

我花了几个小时阅读和尝试教程。 我似乎无法找到一个有效的解决方案,我知道它应该很容易,但我很难与AJAX。 🙁 我想从div中的链接加载Post内容。 以下是我所拥有的。 有人可以帮我解决JavaScript方面的问题吗? 谢谢! 我想在div #loadAjaxHere中加载此代码 感谢您的帮助!!

使用AJAX将WordPress后期内容加载到DIV中

我几天前发布了一个关于如何在我正在开发的自定义Wordpress模板中滚动到单个post的问题 。 我在坚果壳中需要的是在单击特定链接时将单个post加载到定义的DIV中,然后向下滚动到保存新加载内容的DIV。 考虑到Wordpress或任何其他CMS的动态内容特性,该链接的URL不能是绝对的。 不幸的是,在那个时间点没有任何具体的答案,所以我决定窥探一下。 由于主要问题是动态加载内容,我决定放大我如何在Wordpress上使用AJAX来实现它: 到目前为止,我已经从Emanuele Feronato的一篇精彩post( 用Ajax和jQuery加载WordPresspost )中得到了一个小小的想法。 他基本上将postID存储在可点击链接的rel属性中,然后调用它。 好吧,还有一些其他步骤可以使这项工作,但我现在只提到postID的原因是因为它似乎是方程式中唯一不正确的部分; 邮件ID加载到链接的rel属性中,但无法加载到.load函数中。 只是为了让你更好地了解我到目前为止在我的标记中得到了什么: HEADER.PHP中的AJAX / JQUERY $(document).ready(function(){ $.ajaxSetup({cache:false}); $(“.trick”).click(function(){ var post_id = $(this).attr(“rel”); $(“#single-home-container”).html(“loading…”); $(“#single-home-container”).load(“http:///single-home/”,{id:post_id}); return false; }); }); 的index.php <img class="home-bg" src="https://stackoverflow.com/questions/7526113/load-wordpress-post-content-into-div-using-ajax//images/home-bg.jpg” /> <a class="trick" rel="” href=””> <div class="box element col” id=”cat_name; ?>”> SINGLE-HOME.PHP(这是一个定制的模板) <div id="single-home post-“> cat_name; ?> – 仅供记录:当postID无法加载时,我尝试安装Emanuele Feronato演示中使用的特定Kubrick主题,并根据他的指南做了必要的更改,但没有任何效果。 有没有人知道发生了什么,或者是否有其他方法可以将postID动态加载到.load函数中?

自定义下拉选择器显示或隐藏其他Checkout自定义字段

我使用此代码创建自定义结帐字段并重新排序字段: add_filter( ‘woocommerce_checkout_fields’, ‘custom_checkout_billing_fields’ ); function custom_checkout_billing_fields( $fields ) { // 1. Creating the additional custom billing fields // The “status” selector $fields[‘billing’][‘billing_status’][‘type’] = ‘select’; $fields[‘billing’][‘billing_status’][‘class’] = array(‘form-row-wide, status-select’); $fields[‘billing’][‘billing_status’][‘required’] = true; $fields[‘billing’][‘billing_status’][‘label’] = __(‘User status’, ‘my_theme_slug’); $fields[‘billing’][‘billing_status’][‘placeholder’] = __(‘Chose an option’, ‘my_theme_slug’); $fields[‘billing’][‘billing_status’][‘options’] = array( ” => ‘Chose an option’, ‘1’ => ‘Legal entity’, […]