我的博客页面中有6位作者。我有每个作者的简介。我想在他们自己的个人资料下动态显示作者的帖子。我尝试了以下内容,但它显示了所有帖子。使用此代码,它将显示所有配置文件中的帖子,而不是特定的配置文件。我应该做哪些更改?
$current_author = get_query_var(\'author\');
$author_posts= get_posts( \'author=\'.$current_author->id.\'&posts_per_page=1&order=DESC&orderby=post_date\' );
if($author_posts){
echo \'<ul>\';
foreach ($author_posts as $author_post) {
echo \'<li><a href="\'.get_permalink($author_post->ID).\'">\'.$author_post- >post_title.\'</a> </li>\';
}
echo \'</ul>\';
}
我使用以下函数显示有关作者的图像和描述
function ajaxified_function()
{
$post = get_post($_POST[\'post_id\']);
$feat_image = get_the_post_thumbnail($post->ID);
$desc_values = get_post_custom_values("description",$post->ID);
if( is_array( $desc_values ) )
{
foreach($desc_values as $key => $value );
}
echo \'<div id="bloggers_feat_img">\'.$feat_image.\'</div>\'.$post->post_.\'<div class="bloggers_title">\'.$post->post_title.\'</div><div id="bloggers_desc">\'.$value.\'</div><br/><div id="bloggers_postContent">\'.$post->post_content.\'</div><div>\'.$author.\'</div>\';
die();
}
单击链接时,我使用以下js在灯箱中显示上述内容
jQuery(document).ready(function (){
jQuery(\'#options_to_connect a\').on(\'click\',function(event){
event.preventDefault();
var post_id = jQuery(this).parent().attr(\'class\');
jQuery.ajax({
type: "POST",
url: \'http:www.myblog.com/wp-admin/admin-ajax.php\',
data: \'action=ajaxified_function&post_id=\'+post_id,
success: function (msg) {
jQuery(\'#cboxLoadedContent\').html(msg);
},
error: function () {
alert(\'Error\');
}
});
});
});