2012-04-09 40 views
1

我对wordpress和artisteer疯狂。我正在尝试一些过去非常简单的事情 - 在我的博客页面上打开和关闭显示日期和帖子类别的帖子。artisteer wp-theme元数据(日期,类别)丢失

我觉得这是在content.php

global $post; 
theme_post_wrapper(
    array(
     'id' => theme_get_post_id(), 
     'class' => theme_get_post_class(), 
     'title' => theme_get_meta_option($post->ID, 'theme_show_page_title') ? get_the_title() : '', 
     'heading' => theme_get_option('theme_single_article_title_tag'), 
     'before' => theme_get_metadata_icons('date', 'header'), 
     'content' => theme_get_content() 
    ) 
); 

和指导说,你要做的就是插入或在“之前”删除行“日期”。我已经用我的内容文件来回执行,输出中没有任何更改。

我找不到打印它的所有实际代码,wordpress以前是如此简单,以至于所有内容都深入到了10个层次,现在您必须查看数百万个不同的函数才能找到最简单的东西......

正如你可能会说,我通常不与WP工作=)但是,现在这是我的表,我还没有熬夜的最新WP一对夫妇的年... ...

任何输入到哪里我可以找到变量赞赏...

我本来预计在某个时候发现

'发布在'.echo($ date)'。'在分类” .echo($类)

什么的至少远程类似...

回答

2

啊哈!弄清楚了!去h2标签之后所需要的功能之前:

<div class="post-inner article"> 
    <?php echo $thumbnail; 
     if (!art_is_empty_html($title)){ 
      echo '<h2 class="postheader">'.$title.'</h2>'; 
     } 
     echo $before; 
    ?> 
<div class="postcontent"> 
<!-- article-content --> 

的情况下,别人来寻找它离开这里的! :-)

0

所以我跑进我的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