我有一个基于wordpress的视频网站。我想从今天开始在帖子上显示一个图标。我试过用谷歌搜索它,但没有成功。有没有关于如何做到这一点的想法,或者有人有关于它的教程链接?
提前感谢:-)
我有一个基于wordpress的视频网站。我想从今天开始在帖子上显示一个图标。我试过用谷歌搜索它,但没有成功。有没有关于如何做到这一点的想法,或者有人有关于它的教程链接?
提前感谢:-)
您可以使用post时间之间的差异(get_the_time()
) 和当前时间(date()
) -
例如,此代码段添加到函数中。主题的php将向post_class()
如果岗位使用时间少于24小时:
function post_from_today_class($class) {
//add .new-post-today to post_class() if newer than 24hrs
global $post;
if( date(\'U\') - get_the_time(\'U\', $post->ID) < 24*60*60 ) $class[] = \'new-post-today\';
return $class;
}
add_filter(\'post_class\',\'post_from_today_class\');
您可以使用.new-post-today
类以在post div中使用不同的样式。其核心思想是:
if( date(\'U\') - get_the_time(\'U\', $post->ID) < 24*60*60 ) { /*do something*/ };
编辑:或者,在具有自己的php标记的模板中直接使用:<?php if( date(\'U\') - get_the_time(\'U\', $post->ID) < 24*60*60 ) : ?>text<?php endif; ?>
我有一个自定义查询来显示我的自定义帖子类型。posts_per_page 设置为“5”。在“每页管理帖子”设置为“10”(设置=>阅读=>博客页面最多显示10篇帖子)中,我的模板每页列出5篇帖子。如果我有15篇帖子,它必须在3页中显示,but on third page I get 404 error. 因此,我的分页使用管理设置(每页10篇文章)。我怎样才能修复它?global $paged; query_posts(array( \'post_type\' =&g