Wordpress中的Ajax内容 - 需要为书签添加URL

时间:2014-02-04 23:28:14

标签: php jquery ajax wordpress

我正在使用此处找到的技术:How to load Wordpress Post with Ajax onclick将Ajax内容加载到此页面上的wordpress div中:http://dev.riverroadcoffees.com/shop-online/

代码是:

jQuery.noConflict();
jQuery(document).ready(function($){

$.ajaxSetup({cache:false});
$("a.ajax").click(function(){
var post_url = $(this).attr("href");
 var post_id = $(this).attr("rel");
$("#shop").html('<div class="loading"><img src="http://dev.riverroadcoffees.com/blog/wp-content/uploads/2013/12/ajax-loader.gif" /> <span>Loading...</span></div>');
$("#shop").load(post_url);

return false;});
});

CODE IN TEMPLATE:
<article>
<a href="<?php the_permalink(); ?>" rel="<?php the_ID(); ?>" class="ajax"><?php the_post_thumbnail('bag', array('class' => 'alignleft')); ?></a>
<h4><a href="<?php the_permalink(); ?>" rel="<?php the_ID(); ?>" class="ajax"><?php the_title(); ?></a></h4>
<?php the_field('strength'); ?>
</article>

一切都按预期工作......但我没有办法让用户为URL添加书签或引用某个产品的URL。我希望这很简单。但我可能是错的。

0 个答案:

没有答案