【发布时间】:2023-03-09 19:49:01
【问题描述】:
我正在使用 wordpress,将内容从自定义页面加载到我的主题中。我所拥有的是:
header.php
<script type="text/javascript">
$("#another").click(function(){
$("#randomPost")
.text("... loading ...")
.load("/wp/ajax-page/?id=<? echo $id; ?>+cachebuster=" + Math.floor(Math.random()*10001));
return false;
});
</script>
index.php
<a href="#?id=1" id="another">Get another!</a>
ajax_page.php (http://localhost/wp/ajax-page/)
<?php
/*
Template Name: AJAX
*/
?>
<?
$id = $_GET['id'];
?>
<?php
query_posts('showposts=1&id='.$id.'');
the_post();
?>
<a href='<?php the_permalink(); ?>'><?php the_title(); ?></a>
一切正常,这是我发现将数据加载到 wordpress 下的 div 中的更简单方法(使用 javascript)。我的问题是我无法通过 URL 传递 id Var,有什么想法吗?
非常感谢各位,希望你们能帮帮我。
【问题讨论】:
标签: php javascript wordpress url