Php 重复的get_头()

Php 重复的get_头(),php,jquery,wordpress,wordpress-theming,Php,Jquery,Wordpress,Wordpress Theming,重复get_header()问题 我使用jQuery将single-{custom post type}.php插入到首页的ajax容器中。我的单-{custom post type}.php使用wp函数get_header(),而我的首页正在使用get_header()to,因此所有内容都已加载。因此,当我加载自定义帖子时,它会崩溃 如果我从我的单个-{custom post type}.php中删除get_header(),它会正常加载到我的头版。但是,当我在新页面中打开时,不会加载任何内容

重复
get_header()
问题

我使用jQuery将single-
{custom post type}.php
插入到首页的ajax容器中。我的单-
{custom post type}.php
使用wp函数
get_header()
,而我的首页正在使用
get_header()
to,因此所有内容都已加载。因此,当我加载自定义帖子时,它会崩溃

如果我从我的单个-
{custom post type}.php中删除
get_header()
,它会正常加载到我的头版。但是,当我在新页面中打开时,不会加载任何内容,因为我没有
header.php
来加载所有样式、脚本等

我已经尝试使用条件标记,但它不起作用

有什么想法吗

我正在这样做:

在我的frontpage中,我使用data href发送url

<a class="more-info" href="#" data-href="<?php echo the_permalink()?>" ></a>

对于单-{custom post type}.php,您可以检查在使用jquery时添加的查询变量,例如“http://example.com/single-{custom post type}.php?isAjax=1“

然后在php中只需执行以下操作:

if(!isset($_GET['isAjax']) && $_GET['isAjax'] != 1)
{
   get_header();
}
希望这能回答你的问题

编辑:对于ajax调用,如果使用.load(),则

应该这样做

编辑2: 试试这个,然后将变量连接到url

$( ".more-info" ).click(function(e){ 
    e.preventDefault();  
    var page = $(this).attr('data-href'); 
    lateralAnimation.init(page);
});

init : function(page){      
    //changed this line
    $('#ajax-inserted').load(page+"?isAjax=1)   
}   

//#ajax-inserted is where I load the content in my frontpage.   
或者

<a class="more-info" href="#" data-href="<?php echo the_permalink()?>?isAjax=1" ></a>


Ok,应该可以。你能给我一个如何添加那个变量的例子吗?我正在使用load()将单个-{custom post type}.php插入到我的首页中,您的意思是在ajax调用中添加变量吗?如果这回答了你的问题,别忘了把它标记为已回答!谢谢,但不是工作。我将用我的问题来告诉你我是如何加载urlGreat的它工作得很好!!!要编辑的注意事项:添加“在加载结束时()。非常感谢!!!
$( ".more-info" ).click(function(e){ 
    e.preventDefault();  
    var page = $(this).attr('data-href'); 
    lateralAnimation.init(page);
});

init : function(page){      
    //changed this line
    $('#ajax-inserted').load(page+"?isAjax=1)   
}   

//#ajax-inserted is where I load the content in my frontpage.   
<a class="more-info" href="#" data-href="<?php echo the_permalink()?>?isAjax=1" ></a>