【问题标题】:link to archive.php in wordpress链接到 wordpress 中的 archive.php
【发布时间】:2020-06-08 23:58:35
【问题描述】:

我的 single.php 中有以下代码,它输出以下链接

<div class="dt"><?php echo get_the_date();?></div>

<div class="cat">
<?php the_category(', ');?>
</div>

<div class="tag">
  <?php the_tags();?>

</div>

<div class="arc">
<a href="<?php echo get_post_type_archive_link( 'post' ); ?>">Archives</a>
</div>

category 和 tag 的链接都在通过 category.php 和 tag.php 产生输出,但是,我不知道如何链接到 archive.php,我打算在其中显示帖子存档

【问题讨论】:

    标签: php wordpress archive


    【解决方案1】:

    只是为了让您知道没有像您描述的那样默认创建的完整存档页面。

    参考此链接:https://codex.wordpress.org/Creating_an_Archive_Index

    <?php
    
    /*
    Template Name: Archives
    */
    get_header(); ?>
    
    <div id="container">
        <div id="content" role="main">
    
            <?php the_post(); ?>
            <h1 class="entry-title"><?php the_title(); ?></h1>
    
            <?php get_search_form(); ?>
    
            <h2>Archives by Month:</h2>
            <ul>
                <?php wp_get_archives('type=monthly'); ?>
            </ul>
    
            <h2>Archives by Subject:</h2>
            <ul>
                 <?php wp_list_categories(); ?>
            </ul>
    
        </div><!-- #content -->
    </div><!-- #container -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
    

    像这样访问档案:

    <?php wp_get_archives('type=yearly'); ?>
    

    【讨论】:

    • 我知道您建议的解决方案。这不是我要找的。请查看我上面的截图(参见“Flexbox”和“Grid”标签旁边的“Archives”链接)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-22
    • 2018-05-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-07
    相关资源
    最近更新 更多