Php Wordpress作者功能瀑布页面
我正在为我的网站制作一个自定义的博客卷,但我一辈子都不知道如何打印出作者。以下是我到目前为止的情况:Php Wordpress作者功能瀑布页面,php,html,wordpress,Php,Html,Wordpress,我正在为我的网站制作一个自定义的博客卷,但我一辈子都不知道如何打印出作者。以下是我到目前为止的情况: <div id="blog_roll"> <? $args = array('tag__not_in' => '5'); $posts = get_posts($args); foreach($posts as $post) { ?> <div class="waterfall"> <div id="water
<div id="blog_roll">
<?
$args = array('tag__not_in' => '5');
$posts = get_posts($args);
foreach($posts as $post) {
?>
<div class="waterfall">
<div id="waterfall_thumb">
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail(); ?>
</a>
</div>
<div id="waterfall_title">
<a href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a>
</div>
<div id="waterfall_author">
by:<?php the_author();?>on <?php the_time( get_option( 'date_format' ) ); ?>
</div>
<div id="waterfall_exc">
<?php echo apply_filters( 'the_content', $post->post_excerpt ); ?></div>
</div>
<? } ?>
作者:on
任何帮助都将不胜感激 函数只在内部工作™. 要在循环之外获取作者的详细信息,您可以从$post
对象中获取作者ID,并将其与the\u author\u meta()
函数一起使用:
… by: <?php the_author_meta('display_name', $post->post_author); ?> …
我在我的wordpress博客上用这个
$user_url = get_the_author_meta('user_url', $post->post_author);
$user_name = get_the_author_meta('user_nicename', $post->post_author);
echo '<a href="' . $user_url . '" rel="author">' . ' by ' . $user_name . '</a>';
$user\u url=获取作者元数据('user\u url',$post->post\u author);
$user\u name=获取作者元($user\u nicename',$post->post\u author);
回声';
正如其他用户所提到的,作者只在循环中可用,因此您需要使用作者元数据()
$user_url = get_the_author_meta('user_url', $post->post_author);
$user_name = get_the_author_meta('user_nicename', $post->post_author);
echo '<a href="' . $user_url . '" rel="author">' . ' by ' . $user_name . '</a>';