wordpress显示作者所有文章
时间 : 2023-12-30 02:41:02 声明: : 文章内容来自网络,不保证准确性,请自行甄别信息有效性

最佳答案

要在WordPress上显示作者所有的文章,您可以按照以下步骤操作:

1. 登录您的WordPress管理后台,进入“文章”菜单。

2. 在文章管理页面上方,可以看到一个下拉菜单,其中有一个名为“筛选”或“作者”的选项。

3. 点击下拉菜单,并选择您要显示文章的作者名字。

4. 单击“筛选”或“应用”按钮。

5. WordPress将会显示与您选择的作者相关的所有文章。

请注意,这个步骤可能会因为您所使用的WordPress主题或插件的不同而有所不同。如果您在按照上述步骤操作时遇到问题,请参考您所使用的主题或插件的文档或支持页面,或者联系相关的技术支持团队。

其他答案

要在WordPress上显示作者的所有文章,您可以使用以下几种方法:

方法一:通过使用文章归档页面模板

1. 在WordPress后台,导航到“外观”>“编辑器”。

2. 在模板文件列表中,找到并点击"archive.php"或"index.php"(根据您的主题可能有所不同)。

3. 在打开的编辑器中,找到适当的位置(通常在循环代码之前),添加以下代码:

```php

<?php

global $author;

$args = array(

'author' => $author,

'post_type' => 'post',

'posts_per_page' => -1

);

$author_posts = new WP_Query( $args );

if( $author_posts->have_posts() ) :

while( $author_posts->have_posts() ) : $author_posts->the_post();

?>

<div>

<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>

<p><?php the_excerpt(); ?>

</div>

<?php

endwhile;

endif;

wp_reset_postdata();

?>

4. 保存并更新文件。

现在,您的归档页面将显示该作者的所有文章。

方法二:通过使用独立页面模板

1. 在WordPress后台,导航到“页面”>“新增”。

2. 输入页面标题,并在内容部分插入以下代码:

```php

<?php

/*

Template Name: Author Posts

*/

get_header();

global $author;

$args = array(

'author' => $author,

'post_type' => 'post',

'posts_per_page' => -1

);

$author_posts = new WP_Query( $args );

if( $author_posts->have_posts() ) :

while( $author_posts->have_posts() ) : $author_posts->the_post();

?>

<div>

<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>

<p><?php the_excerpt(); ?>

</div>

<?php

endwhile;

endif;

wp_reset_postdata();

get_footer();

?>

3. 将该页面保存为独立模板,并发布。

4. 在外观>自定义>页面设置中,选择上述模板为相应的页面。

现在,您的页面将显示该作者的所有文章。

方法三:使用插件

如果您不熟悉编写代码,您也可以使用WordPress插件来实现这一功能。以下是一些常用的插件:

- Author Post Widget(作者文章小工具):将作者的文章显示为小工具的形式。

- All-in-One WP Author List(全能作者列表):创建一个作者列表页面,显示每位作者的文章。

- List Author Posts(列出作者的文章):创建一个页面,显示指定作者的所有文章。

安装并激活适合您需求的插件,然后根据插件的文档和设置说明进行配置即可。

无论选择哪种方法,都可以轻松地在WordPress网站上显示作者的所有文章。