您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
25. 其他归档页中调用和展示数据
发布时间:2023-03-14 21:10:43编辑:雪饮阅读()
tag归档页
首先是tag归档页,则于主题目录中建立tag.php
然后这里是查看tag本身数据与tag归档页文章列表,则如:
<div style="border:1px solid pink;">
<div style="display:flex;justify-content: center;">
<div style="border:1px solid red; width:90%;">
<p>tag本身的数据 get_queried_object:<?php print_r(get_queried_object());?></p>
<p>tag归档页网址 get_tag_link:<?php echo get_tag_link(get_queried_object());?></p>
</div>
</div>
</div>
<?php if(have_posts()):?>
<?php while(have_posts()):the_post();?>
<div style="border:1px solid pink;">
<div style="display:flex;justify-content: center;">
<div style="border:1px solid red; width:90%;">
<p>文章标题:<?php the_title();?></p>
</div>
</div>
</div>
<?php endwhile; ?>
<?php else: ?>
<p>对不起,暂时没有任何内容!</p>
<?php endif;?>
作者归档页
类同tag归档页,于当前使用主题目录建立author.php,就是作者归档页获取函数名有点长并且不用传参。
<div style="border:1px solid pink;">
<div style="display:flex;justify-content: center;">
<div style="border:1px solid red; width:90%;">
<p>作者本身的数据 get_queried_object:<?php print_r(get_queried_object());?></p>
<p>作者归档页网址 get_the_author_posts_link:<?php echo get_the_author_posts_link();?></p>
</div>
</div>
</div>
<?php if(have_posts()):?>
<?php while(have_posts()):the_post();?>
<div style="border:1px solid pink;">
<div style="display:flex;justify-content: center;">
<div style="border:1px solid red; width:90%;">
<p>文章标题:<?php the_title();?></p>
</div>
</div>
</div>
<?php endwhile; ?>
<?php else: ?>
<p>对不起,暂时没有任何内容!</p>
<?php endif;?>
日期归档页
类同tag归档页,就是日期本身数据不是通过查询对象拿到的,get_the_date拿到,且比较简洁。并且好像是没有获取日期归档页链接的函数。
则在当前使用主题目录中建立date.php如:
<div style="border:1px solid pink;">
<div style="display:flex;justify-content: center;">
<div style="border:1px solid red; width:90%;">
<p>日期本身的数据 get_the_date:<?php echo get_the_date();?></p>
<p>日期本身的数据 get_the_date(格式化):<?php echo get_the_date("Y-m-d");?></p>
</div>
</div>
</div>
<?php if(have_posts()):?>
<?php while(have_posts()):the_post();?>
<div style="border:1px solid pink;">
<div style="display:flex;justify-content: center;">
<div style="border:1px solid red; width:90%;">
<p>文章标题:<?php the_title();?></p>
</div>
</div>
</div>
<?php endwhile; ?>
<?php else: ?>
<p>对不起,暂时没有任何内容!</p>
<?php endif;?>
关键字词:归档页
相关文章
-
无相关信息