If you paste a Tweet URL to your post, Wordpress will nicely render it.
But if I load posts via Ajax, the URL gets replaced by a Blockquote, but not with the nicely rendered one. The class of the Blockquote is twitter-tweet
and not, as intended twitter-tweet-rendered
with all that extra stuff.
This is what it looks like loaded via Ajax:
And this is what it looks like loaded by normal request:
So is there any Javascript action that I could fire to render that Twitter Feed?
This is how I load it:
$.ajax({
url: link, // this is generated via the "next_posts" link
success: function(respond) {
// get the right content
var $result = $(respond).find('.content article');
// append the content
$('.content').append( $result );
},
error: function(html) {
}
});
Alternate Ajax request:
$.post(
my_global.ajaxurl,
{
action : 'return_tweet_post'
},
function( respond ) {
// append it
}
And the PHP action for it:
add_action( 'wp_ajax_nopriv_return_tweet_post', 'return_tweet_post' );
add_action( 'wp_ajax_return_tweet_post', 'return_tweet_post' );
function return_tweet_post() {
$my_query = new WP_Query('p=1165');
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) {
$my_query->the_post();
the_content();
}
}
exit;
}
Gives the same result.
wp_ajax
by "properly request it"), but it returns the same result