gpt4 book ai didi

php - WordPress 内容未在 .load jQuery 函数上检索

转载 作者:行者123 更新时间:2023-12-01 05:50:59 24 4
gpt4 key购买 nike

我正在尝试通过 .load jQuery 函数从 WordPress query_posts 外部 php 文件获取帖子。

我得到了正确的 html 代码,但代码的 WordPress 循环部分未加载。

我的代码是:

HTML:

<article class="delivery-individual">
<!-- # CONTENT HERE -->
</article>

jQuery:

    <script>
$(document).ready(function(){
$(".delivery-individual").load("<?php bloginfo('template_directory'); ?>/temakis.php",
function() {window.alert('Load was performed.');});
});
</script>

外部文件:

<h3>Temakis</h3>

<?php
$args = array(
'post_type' => 'post',
'category_name' => 'temakis');
query_posts($args);
while (have_posts()) : the_post();
?>

<div class="item-individual">
<img src="<?php the_field("imagem-produto");?>" width="150" height="150" title="<?php echo get_the_title(); ?> "/>
<div class="item-individual-info">
<h4><?php echo get_the_title(); ?></h4>
<p class="descricao-delivery"><? echo get_post_field('post_content'); ?></p>
<p class="valor-delivery">R$ <? the_field("preco"); ?></p>
</div>
</div>

<?php endwhile; ?>
<?php wp_reset_query(); ?>

请求没问题,因为我正确获取了 h3。

有人可以帮助我吗?

谢谢!

最佳答案

将 temakis.php 文件放入根文件夹并加载该文件,

"<?php home_url(); ?>/temakis.php"

关于php - WordPress 内容未在 .load jQuery 函数上检索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22389015/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com