Here is the function. It’s uses jquery-1.2.3.pack.js
<script type="text/javascript">
var pageUrl = new Array();
pageUrl[1] = "wp-content/themes/Million/tab1.php";
pageUrl[2] = "wp-content/themes/Million/tab2.php";
pageUrl[3] = "wp-content/themes/Million/tab3.php";
pageUrl[4] = "wp-content/themes/Million/tab4.php";
pageUrl[5] = "wp-content/themes/Million/tab5.php";
function loadTab(id)
{
if (pageUrl[id].length > 0)
{
$("#preloader-ajax").show();
$.ajax(
{
url: pageUrl[id],
cache: false,
success: function(message)
{
$("#tabcontent").empty().append(message);
$("#preloader-ajax").hide();
}
});
}
}
$(document).ready(function()
{
$("#preloader-ajax").hide();
$("#tab1").click(function()
{
loadTab(1);
});
$("#tab2").click(function()
{
loadTab(2);
});
$("#tab3").click(function()
{
loadTab(3);
});
$("#tab4").click(function()
{
loadTab(4);
});
});
</script>
This would be tab3.php but for some reason it will not query the posts once it’s called through ajax.
<script type="text/javascript">
function instertContent($pagename){
$temp = $wp_query;
$wp_query = null;
$wp_query = new WP_Query();
$wp_query->query('pagename='.$pagename.'&static=true');
while ($wp_query->have_posts()) : $wp_query->the_post();
apply_filters('the_content', the_content());
endwhile;
$wp_query = null; $wp_query = $temp;
rewind_posts();
}
function instertExcerpt($pagename){
$temp = $wp_query;
$wp_query = null;
$wp_query = new WP_Query();
$wp_query->query('pagename='.$pagename.'&static=true');
while ($wp_query->have_posts()) : $wp_query->the_post();
apply_filters('the_excerpt', the_excerpt());
endwhile;
$wp_query = null; $wp_query = $temp;
rewind_posts();
}
</script>