所以我跑进我的Artisteer的主题没有任何后元数据(发布日期,类别等)的这个问题。我在艺术家设计程序中禁用了他们,因为我不希望整个页面看起来像博客,而是一个专业页面。
但是,后来我意识到我确实想要我的新闻版块(这实际上只是一个博客页面)的发布日期,发布类别等数据。
我该如何恢复?
原来,这比你想象的要难...在WP和artisteer的早期版本中,你可以找到处理输出的文件,比如索引,页面等等,但现在它全部结束了函数互相呼叫=)
它是这样的: WP中的每个页面都有一个模板文件(可以在创建页面时指定),在WP Codex中阅读更多关于页面模板的内容。 您的博客页面运行的是home.php或archive.php(取决于您是否正在查看帖子的存档或只是定期的“主页”项目,我称之为我的“新闻”,因为博客只是一个小我的网站的新闻部分)。
打印出的职位循环是这样的:
/* Start the Loop */
while (have_posts()) {
the_post();
get_template_part('content', '');
}
所以所有的,可以参考后输出此页面模板文件控制是使用内容过滤模板。在您的artisteer 3.1主题中,您将拥有多个content.php文件,上面的函数将调用content.php,但是您可以为您的页面设置content-page.php等等。让我们来看看我的content.php ...
global $post;
theme_post_wrapper(
array(
'id' => theme_get_post_id(),
'class' => theme_get_post_class(),
'thumbnail' => theme_get_post_thumbnail(),
'title' => theme_get_meta_option($post->ID, 'theme_show_page_title') ? get_the_title() : '',
'heading' => theme_get_option('theme_'.(is_single()?'single':'posts').'_article_title_tag'),
'before' => theme_get_metadata_icons('date,category', 'header'),
'content' => theme_get_excerpt(),
'after' => theme_get_metadata_icons('', 'footer')
)
);
所以这个文件真正做的是确定哪些数据部分包含在这个模板中。当我在这里钻了下来时,我开始恼火......哪里是打印我的HTML元素的实际代码?我可以在哪里开始“黑客”我的主题?正如你可能看到的,上面的'before'的行包含项目的'data',category'和一个额外的样式设置值'header'。因此,让我们看看我们的主题的functions.php该功能...
function theme_get_metadata_icons($icons = '', $class=''){
global $post;
if (!is_string($icons) || theme_strlen($icons) == 0) return;
$icons = explode(",", str_replace(' ', '', $icons));
if (!is_array($icons) || count($icons) == 0) return;
$result = array();
for($i = 0; $i < count($icons); $i++){
$icon = $icons[$i];
switch($icon){
case 'date':
$result[] = '<span class="art-postdateicon">' . sprintf(__('<span class="%1$s">Published</span> %2$s', THEME_NS),
'date',
sprintf('<span class="entry-date" title="%1$s">%2$s</span>',
esc_attr(get_the_time()),
get_the_date()
)
) . '</span>';
break;
case 'category':
$categories = get_the_category_list(', ');
if(theme_strlen($categories) == 0) break;
$result[] = '<span class="art-postcategoryicon">' . sprintf(__('<span class="%1$s">Posted in</span> %2$s', THEME_NS), 'categories', get_the_category_list(', ')) . '</span>';
break;
//other options such as author etc. are included here by default, I took them out for the sake of this example...
}
}
$result = implode(theme_get_option('theme_metadata_separator'), $result);
if (theme_is_empty_html($result)) return;
return "<div class=\"art-post{$class}icons art-metadata-icons\">{$result}</div>";
}
所以该功能只提取了一些数据,并把它封装在一些主题造型,但我仍然没有找到,我可以注释掉包含“posted by”等信息的实际html元素。 请记住我已经失去了日期戳记,所以我认为它已被注释掉了。
最后看的地方现在是函数theme_post_wrapper(),如果你退后一步,你会看到theme_post_wrapper()函数依次调用上面提取数据并封装它的函数在一些造型元素。你会认为这个函数会在functions.php中的某个地方?但是,没有......对于功能theme_post_wrapper目录搜索(表明,它是在主题文件库/ wrappers.php它看起来是这样的:
function theme_post_wrapper($args = '') {
$args = wp_parse_args($args,
array(
'id' => '',
'class' => '',
'title' => '',
'heading' => 'h2',
'thumbnail' => '',
'before' => '',
'content' => '',
'after' => ''
)
);
/*
var_dump($args);
die;
*/
extract($args);
if (theme_is_empty_html($title) && theme_is_empty_html($content)) return;
if ($id) {
$id = ' id="' . $id . '"';
}
if ($class) {
$class = ' ' . $class;
}
?>
<div class="art-box art-post<?php echo $class; ?>"<?php echo $id; ?>>
<div class="art-box-body art-post-body">
<div class="art-post-inner art-article">
<?php
if (!theme_is_empty_html($title)){
echo '<'.$heading.' class="art-postheader">'$before.': '.$title.' <span class="published_date">('.$after.')</span></'.$heading.'>';
//original: echo '<'.$heading.' class="art-postheader">'.$title.'</'.$heading.'>';
}
echo $thumbnail;
?>
<div class="art-postcontent">
<!-- article-content -->
<?php echo $content; ?>
<!-- /article-content -->
</div>
<div class="cleared"></div>
<?php
?>
</div>
<div class="cleared"></div>
</div>
</div>
这里是我的元数据元素最后的印刷,现在我感到宾至如归,再次感受到了这个世界的一切,我再一次感谢Artisteer,虽然它有点混乱,并且花费了相当多的时间来研究这个问题上的螺母和螺栓。我的问题的解决方案:Artisteer的工作原理如下:当您选择不在主题中包含日期或作者元数据时,artisteer不会仅关闭某个选项或将这些元素的打印代码注释掉, t生成t帽子代码。所以我不得不手动把它放回去。足够公平 - 我猜artisteer的主题不会被黑客攻击并以这种方式进行调整,但我仍然喜欢他们比那些二十世纪和二十世纪主题的逻辑更好= p