wordpress分类目录不显示文章日期
时间 : 2023-12-13 00:28:02声明: : 文章内容来自网络,不保证准确性,请自行甄别信息有效性

最佳答案

要在WordPress分类目录中不显示文章日期,您可以通过以下步骤进行设置:

1. 登录到您的WordPress后台。

2. 导航到“外观”>“编辑器”。

3. 在右侧的“模板文件”列表中,找到名为“category.php”的文件并将其选中。

4. 在代码编辑器中,找到与日期相关的代码。通常,这个代码块看起来像这样:

<?php the_date(); ?>

或者

<?php the_time(); ?>

5. 将该代码删除或注释掉。您可以使用HTML注释(`<!-- -->`)将该代码块注释掉,如下所示:

<!-- <?php the_date(); ?> -->

<!-- <?php the_time(); ?> -->

6. 单击“更新文件”按钮保存更改。

现在,通过访问您的分类目录页面,您将看到已经不再显示文章的日期了。请注意,如果您使用自定义主题,可能需要在其他模板文件中进行类似的更改,例如`archive.php`或`index.php`。

其他答案

要在WordPress分类目录中显示文章日期,您需要进行以下几个步骤:

1. 登录您的WordPress后台。

2. 在左侧导航菜单中选择“外观”>“编辑器”。

3. 在编辑器的右侧,您可以看到一个“主题文件”列表。点击列表中的“archive.php”文件。

4. 在archive.php文件中搜索以下代码:

<header class="page-header">

<?php

the_archive_title( '<h1 class="page-title">', '</h1>' );

the_archive_description( '<div class="taxonomy-description">', '</div>' );

?>

</header><!-- .page-header -->

5. 将上述代码替换为以下代码:

<header class="page-header">

<h1 class="page-title">

<?php if ( is_day() ) : ?>

<?php printf( __( 'Daily Archives: %s', 'textdomain' ), get_the_date() ); ?>

<?php elseif ( is_month() ) : ?>

<?php printf( __( 'Monthly Archives: %s', 'textdomain' ), get_the_date( _x( 'F Y', 'monthly archives date format', 'textdomain' ) ) ); ?>

<?php elseif ( is_year() ) : ?>

<?php printf( __( 'Yearly Archives: %s', 'textdomain' ), get_the_date( _x( 'Y', 'yearly archives date format', 'textdomain' ) ) ); ?>

<?php else : ?>

<?php _e( 'Archives', 'textdomain' ); ?>

<?php endif; ?>

</h1>

</header><!-- .page-header -->

6. 点击“更新文件”按钮保存并应用更改。

7. 刷新您的网站,现在应该能在分类目录页面中看到文章日期。

请注意,在编辑主题文件之前,请务必备份您的WordPress网站,以防意外情况发生。此外,如果您使用的是一个自定义主题或插件,则可能需要在相应的文件中进行类似的更改。