Php 在WordPress中显示搜索词(标记/存档)
我目前正在WordPress中使用一个侧栏,并在侧栏中显示“存档”和“流行标签” 例如,归档代码Php 在WordPress中显示搜索词(标记/存档),php,html,wordpress,loops,Php,Html,Wordpress,Loops,我目前正在WordPress中使用一个侧栏,并在侧栏中显示“存档”和“流行标签” 例如,归档代码 <div class="populartags"> <?php $tags = get_tags(); $html = '<div class="post_tags">'; foreach ( $tags as $tag ) { $tag_link = get_tag_link( $tag->term_id );
<div class="populartags">
<?php
$tags = get_tags();
$html = '<div class="post_tags">';
foreach ( $tags as $tag ) {
$tag_link = get_tag_link( $tag->term_id );
$html .= "<a style='color:#333;' href='{$tag_link}' title='{$tag->name} Tag' class='{$tag->slug}'>";
$html .= "{$tag->name}</a>";
}
$html .= '</div>';
echo $html;
?>
</div>
这将显示已在帖子上使用的所有标记。
我还有档案(日期)——
这些页面,转到archive.php,这很好。
我正在努力实现的目标。是一行文字,上面写着
'这是(存档/标签)的帖子。'
所以,如果我看了2015年5月的帖子。它会说“这是2015年5月的帖子”
有人有什么想法吗?你需要编辑
archive.php
加上
<?php if( is_month() ) { ?> // Check if month based archive
<?php echo 'Here are the posts for'; ?>
<?php the_time('F Y');
} ?>
//检查是否基于月份存档
如果人们仍在查看,则显示日期、标签和结果数:
<?php echo 'Search Results'; ?>
<?php echo 'Displaying ' . count($posts) . ' results for '; ?>
<?php echo $tag ?>
<?php if( is_month() ) { ?>
<?php the_time('F Y');
} ?>
您只想显示文本?是的,只是为了让他们知道他们看到的页面结果,这样就可以通过获取按下的日期来显示存档日期?标签呢?我已经编辑了代码。如果档案是每月的,它会返回文本。我明天第一件事就是要试试这个。那标签呢,知道吗?我不确定标签是否按日期分类。我只看过每月、每年的档案。如果我错了,请纠正我。如果标签是月刊格式,上面的应该可以。抱歉。标签只是文本,用户可以将其添加到任何帖子中
<?php echo 'Search Results'; ?>
<?php echo 'Displaying ' . count($posts) . ' results for '; ?>
<?php echo $tag ?>
<?php if( is_month() ) { ?>
<?php the_time('F Y');
} ?>