我在我的网站上使用wordpress主题。问题很简单,我想在我的文章中添加一个内联注释、注意事项、警告性引用等图片。我该怎么做?有什么插件或方法可以做到这一点吗?
如何在文本内添加注释、警告、警告引号?
2 个回复
SO网友:Johansson
你可以加入the_content
过滤并在每篇帖子后添加您的注释。然后你可以把它设计成一个很好的引用。
add_filter(\'the_content\',\'add_my_note\');
function add_my_note($content){
// Write your note here
$note = \'
<div class="my-note">
<h3>Note Header</h3>
<p>Note body</p>
</div>\';
// Append the note to the content
$content = $content . $note;
// Return the modified content
return $content;
}
这会将注释添加到您的帖子内容中。现在是时候改变它了。.my-note {
display:block;
background:lightgray;
border-width: 0 0 0 3px;
border-color:grey;
color:black;
border-style:solid;
padding: 1em;
}
.my-note h3 {
display:block;
font-size: 2em
}
.my-note p {
display:block;
font-size : 1em;
}
我为你做了一些基本的造型,你可以根据自己的口味来改变,SO网友:BenB
在你的主题中运行管理仪表板的CSS。
wp_enqueue_style( \'wp-admin\' );
那么你可以使用WordPress admin alerts CSS文档示例:
<div class="notice notice-success is-dismissible">
<p><?php _e( \'Done!\', \'sample-text-domain\' ); ?></p>
</div>
如果您有bootstrap based theme, 那么你可以使用bootstrap alerts css styles, 或者在主题中包含引导css,但此选项会影响站点设计中的其他元素。与您问题中的屏幕截图类似的文档示例:
<div class="alert alert-info" role="alert">
<strong>Heads up!</strong> This alert needs your attention, but it\'s not super important.
</div>
结束