在 Wordpress post 标题前添加标签 "Leak"、"Rumour"、"Confirmed"
Labels "Leak", "Rumour", "Confirmed" before Wordpress post title
我们是新闻站点,希望使用类似这样的东西。有些人就是看不懂文中写的是泄密或已确认信息。我们也想通过这种方式来防止这种情况。是否可以以任何方式做/创建它?我一直在寻找插件,一些代码,但我什么也没找到。可能吗?
或者,我们认为我们会创建类别并将它们显示在文章标题之前(就一个字,leak,confirmed等),但网站适用于 multi-categories.
如果有人能提供建议,我会很高兴。
谢谢。
我将使用 jQuery
。我更喜欢使用 Code Snippets 插件将自定义 php functions
或 javascript
添加到任何 wordpress 主题。
安装并激活 Code Snippets 后,单击 Add New 并粘贴下面的代码。我将每个标签硬编码到代码中,购买它可以通过动态解决方案进行改进。由于我没有看到您的 html 输出,所以我只是写了一个近似解。
add_action( 'wp_footer', function () { ?>
<script>
(function( $ ) {
$(document).ready(
function(){
$(".tag-rumor .title").prepend ('<span class="customtag">Rumor</span>');
$(".tag-leak .title").prepend ('<span class="customtag">Lean</span>');
$(".tag-confirmed .title").prepend ('<span class="customtag">Confirmed</span>');
});
})(jQuery);
</script>
<?php } );
CSS customtag
class
的代码
.customtag {
display: inline-block;
background: orange;
padding: 5px 10px;
margin-right: 10px;
}
我在这里测试过,它有效:https://codepen.io/ozgursar/pen/KKMEENj
我们是新闻站点,希望使用类似这样的东西。有些人就是看不懂文中写的是泄密或已确认信息。我们也想通过这种方式来防止这种情况。是否可以以任何方式做/创建它?我一直在寻找插件,一些代码,但我什么也没找到。可能吗?
或者,我们认为我们会创建类别并将它们显示在文章标题之前(就一个字,leak,confirmed等),但网站适用于 multi-categories.
如果有人能提供建议,我会很高兴。
谢谢。
我将使用 jQuery
。我更喜欢使用 Code Snippets 插件将自定义 php functions
或 javascript
添加到任何 wordpress 主题。
安装并激活 Code Snippets 后,单击 Add New 并粘贴下面的代码。我将每个标签硬编码到代码中,购买它可以通过动态解决方案进行改进。由于我没有看到您的 html 输出,所以我只是写了一个近似解。
add_action( 'wp_footer', function () { ?>
<script>
(function( $ ) {
$(document).ready(
function(){
$(".tag-rumor .title").prepend ('<span class="customtag">Rumor</span>');
$(".tag-leak .title").prepend ('<span class="customtag">Lean</span>');
$(".tag-confirmed .title").prepend ('<span class="customtag">Confirmed</span>');
});
})(jQuery);
</script>
<?php } );
CSS customtag
class
.customtag {
display: inline-block;
background: orange;
padding: 5px 10px;
margin-right: 10px;
}
我在这里测试过,它有效:https://codepen.io/ozgursar/pen/KKMEENj