reusable tags snippets

This commit is contained in:
cupcakearmy 2019-05-06 21:35:20 +02:00
parent db1aa0d0d8
commit 967d0ef870
2 changed files with 25 additions and 9 deletions

View File

@ -1,9 +0,0 @@
<?php
$tags = get_the_tags();
if ($tags) { ?>
<div class="tags">
<?php foreach ($tags as $tag) { ?>
<a class="tag" href="<?= get_tag_link($tag->term_id); ?>"><?= $tag->name; ?></a>
<?php } ?>
</div>
<?php }

25
liquet/tags.php Normal file
View File

@ -0,0 +1,25 @@
<?php
function render_all_tags() {
$tags = get_tags( [ 'orderby' => 'count', 'order' => 'desc' ] );
if ( $tags ) { ?>
<div class="tags">
<?php foreach ( $tags as $tag ) { ?>
<a class="tag" href="<?= get_tag_link( $tag->term_id ); ?>"><?= $tag->name; ?>
<b><?= $tag->count ?></b></a>
<?php } ?>
</div>
<?php }
}
function render_current_tags() {
$tags = get_the_tags();
if ( $tags ) { ?>
<div class="tags">
<?php foreach ( $tags as $tag ) { ?>
<a class="tag" href="<?= get_tag_link( $tag->term_id ); ?>"><?= $tag->name; ?></a>
<?php } ?>
</div>
<?php }
}