jQuery(document).ready(function($) {
$('a.ttLinks').click(function() {
var url= $(this).attr("href");
$("#inCenter>[id^=featuredv]").load(url);
return false;
});
});
I tried making a script that loads the contents of a link when it is clicked rather than reloading the page. I'm not certain why but it seems that when a link is clicked it loads the actual page that I'm currently on into my featuredv div instead of just the contents of the post. I think when a permalink is clicked on, it loads the post into index.php and then returns the page to me.
<div id="ttContent">
<?php
query_posts('meta_key=featuredt&posts_per_page=5');
if (have_posts()) : while (have_posts()) : the_post();
?>
<div id="featuredt-<?php echo $wp_query->current_post;?>">
<a class="ttLinks" rel="<?php the_permalink(); ?>" href="<?php echo the_permalink();?>">
<?php echo get_post_meta($post->ID, 'featuredt', TRUE);?></a></div>
<?php endwhile;
endif;
?>
</div>
the code above is the php I'm using to generate my links, I was originally using href but after reading another post, Load Wordpress post content into DIV using AJAX , I thought maybe I should try using the rel tag instead, there wasn't a difference since either way the url is the same but I was tired and trying anything I could.
<div id="inCenter">
<?php
query_posts('meta_key=featuredt&posts_per_page=1');
if (have_posts()) : while (have_posts()) : the_post();?>
<div id="featuredv-<?php echo $wp_query->current_post;?>">
<?php echo $post->post_content;?></div>
<?php endwhile;
endif;
?>
</div>
And this code is what generates the content that I want to replace when a link is clicked. What firebug seems to be showing is that the first time a link is clicked it sends a GET request for the permalink which in the page it's displayed in, the second time any of the links are clicked it sends 4 GET requests for the permalink, the next time 12 and so on. I'm not using wordpress as a blog and I don't have a place for the posts to load to so maybe the posts are loading using the index.php by default when the GET request is made? Thanks again for the help.