艺人WP主题元数据(日期,类别)丢失


artisteer wp-theme metadata (date, category) lost

我对wordpress和artisteer发疯了。我正在尝试一些过去非常简单的事情 - 在我的博客页面上打开和关闭我的帖子的日期和帖子类别的显示。

我在内容中找到了这一点.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($category)中

或者至少远程相似的东西...

啊哈! 想通了! before函数需要在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 -->

把这个留在这里,以防别人来找它! :-)

所以我遇到了这个问题,在我的 Artisteer 主题中没有任何帖子元数据(发布日期、类别等)。我在艺人设计程序中禁用了它们,因为我不希望我的整个页面看起来像一个博客,而是一个专业页面。

然而,后来我意识到我确实想要我的新闻部分(实际上只是一个博客页面)的发布日期、帖子类别等数据。

我该如何取回它?

事实证明,这比你想象的要难一些......在早期版本的WP和artisteer中,你可以找到处理输出的文件,即索引,页面等,但现在它都包含在相互调用的函数中=)

它是这样的:WP中的每个页面都有一个模板文件(可以在创建页面时指定),阅读有关WP Codex中页面模板的更多信息。您的博客页面脱离主页.php或存档.php(取决于您是查看帖子存档还是只是常规的"主页"项目,我称我的"新闻",因为博客只是我网站的一个小新闻部分)。

打印出帖子的循环如下所示:

/* Start the Loop */ 
while (have_posts()) {
    the_post();
    get_template_part('content', '');
}

因此,此页面模板文件中有关帖子输出的所有控制都是要使用的内容过滤器模板。在你的 artisteer 3.1 主题中,你会有很多内容.php文件,上面的函数会调用内容.php但你可以有一个内容页面.php用于你的页面等。让我们来看看我的内容.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 元素的实际代码在哪里?我在哪里可以开始"入侵"我的主题?如您所见,上面的"之前"行包含项目"数据,类别"和样式的附加值"标题"。因此,让我们在我们的主题函数中看一下该函数.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>";
    }

因此,该函数仅提取一些数据,并将其包装在某些主题样式中,但我仍然没有找到可以注释掉包含"发布者"等信息的实际 html 元素的地方。请记住,我丢失了日期戳,所以我认为它在某处被注释掉了。

最后要看的地方现在是函数 theme_post_wrapper(),如果你退后一步,你会看到 theme_post_wrapper() 是调用上述函数的函数,该函数提取数据并将其包装在一些样式元素中。你会认为这个函数应该在函数中的某个地方.php对吧?但是不...对函数 theme_post_wrapper() 的目录搜索显示它位于主题文件库/包装器.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 不仅会关闭选项或注释掉用于打印这些元素的代码,它实际上根本不会生成该代码。所以我不得不手动把它放回去。很公平 - 我想艺人主题不是以这种方式被黑客入侵和调整的,但我仍然比那些二十一和二十一主题的逻辑更喜欢它们 =p