我目前正在一个新闻网站上工作,并使用Wordpress存档功能在一个提要中显示我的所有帖子(当你点击帖子标题时,你会被带到源网站)。我需要为这些帖子(新闻文章的来源)添加另一个元数据。.
这就是它目前的样子,我需要与日期和作者内联的源代码。
我使用高级自定义字段插件为每篇文章创建了一个自定义元框,我可以在其中输入文章的源代码。这似乎工作正常,但我不知道如何在归档页面上显示它。
这是我添加到循环归档的代码。php,因为我想在这里显示自定义字段。但什么都没发生。我从许多不同的网站上获得了这段代码,这使得显示自定义元数据看起来很容易。(这一切都是以儿童为主题的,我使用的主题是报纸)
如何修复此问题?
档案文件php:
<?php get_header();
$td_archive_title = \'\';
if (is_day()) {
$td_archive_title .= __(\'Daily Archives:\', \'newspaper\' ) . \' \' . get_the_date();
} elseif (is_month()) {
$td_archive_title .= __(\'Monthly Archives:\', \'newspaper\') . \' \' . get_the_date(\'F Y\');
} elseif (is_year()) {
$td_archive_title .= __(\'Yearly Archives:\', \'newspaper\') . \' \' . get_the_date(\'Y\');
} else {
$td_archive_title .= __(\'Archives\', \'newspaper\');
}
?>
<div class="td-main-content-wrap td-container-wrap">
<div class="td-container">
<div class="td-crumb-container">
<?php echo tagdiv_page_generator::get_breadcrumbs(array(
\'template\' => \'archive\',
)); ?>
</div>
<div class="td-pb-row">
<div class="td-pb-span8 td-main-content">
<div class="td-ss-main-content">
<div class="td-page-header">
<h1 class="entry-title td-page-title">
<span><?php echo esc_html( $td_archive_title ) ?></span>
</h1>
</div>
<?php
get_template_part(\'loop-archive\');
?>
</div>
</div>
<div class="td-pb-span4 td-main-sidebar">
<div class="td-ss-main-sidebar">
<?php dynamic_sidebar( \'td-default\' ) ?>
</div>
</div>
</div>
</div>
</div>
<?php get_footer(); ?>
存档循环:
<?php
$post_count = 1;
$column_count = 1;
$span = \'span6\';
$column_break = 2;
$is_404 = false;
if( is_404() ) {
$is_404 = true;
$column_break = 3;
$span = \'span4\';
$args = array(
\'post_type\'=> \'post\',
\'showposts\' => 6,
\'ignore_sticky_posts\' => true
);
query_posts($args);
}
if (have_posts()) {
while ( have_posts() ) : the_post();
if( $column_count == 1 ) { ?>
<div class="td-block-row">
<?php } ?>
<div class="td-block-<?php echo esc_attr( $span ) ?>">
<div <?php post_class(\'td_module_1 td_module_wrap clearfix\') ?> >
<div class="td-module-image">
<div class="td-module-thumb">
<?php
if ( current_user_can(\'edit_published_posts\') ) {
edit_post_link(\'Edit\', \'\', \'\', \'\', \'td-admin-edit\');
}
?>
<a href="<?php the_permalink() ?>" rel="bookmark" class="td-image-wrap" title="<?php the_title_attribute() ?>">
<?php
$post_thumbnail_url = \'\';
if( get_the_post_thumbnail_url(null, \'medium_large\') != false ) {
$post_thumbnail_url = get_the_post_thumbnail_url(null, \'medium_large\');
} else {
$post_thumbnail_url = get_template_directory_uri() . \'/images/no-thumb/medium_large.png\';
}
?>
<img class="entry-thumb" src="<?php echo esc_url($post_thumbnail_url) ?>" alt="<?php the_title() ?>" title="<?php echo esc_attr(strip_tags(the_title())) ?>" />
</a>
</div>
<?php
$categories = get_the_category();
if( !empty( $categories ) ) {
$cat_link = get_category_link($categories[0]->cat_ID);
$cat_name = $categories[0]->name; ?>
<a class="td-post-category" href="<?php echo esc_url($cat_link) ?>"><?php echo esc_html($cat_name) ?></a>
<?php } ?>
</div>
<?php
$source = get_post_meta($post->ID, \'source\', true);
if ($source) { ?>
<p>Source: <? echo $source; ?></p>
<?php
} else {
// do nothing;
}
?>
<h3 class="entry-title td-module-title">
<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute() ?>">
<?php the_title() ?>
</a>
</h3>
<div class="td-module-meta-info">
<div class="td-post-author-name">
<a href="<?php echo esc_url(get_author_posts_url(get_the_author_meta( \'ID\' ))) ?>"><?php the_author() ?></a>
<span> - </span>
</div>
<span class="td-post-date">
<time class="entry-date updated td-module-date" datetime="<?php echo esc_html(date(DATE_W3C, get_the_time(\'U\'))) ?>" ><?php the_time(get_option(\'date_format\')) ?></time>
</span>
<div class="td-module-comments">
<a href="<?php comments_link() ?>">
<?php comments_number(\'0\',\'1\',\'%\') ?>
</a>
</div>
</div>
</div>
</div>
<?php
if( $column_count == $column_break || $post_count == $wp_query->post_count ) { ?>
</div> <?php
$column_count = 1;
} else {
$column_count++;
}
$post_count++;
endwhile;
if( !$is_404 ) {
tagdiv_page_generator::get_pagination();
}
} else { ?>
<div class="no-results td-pb-padding-side">
<h2><?php esc_html_e(\'No posts to display\', \'newspaper\') ?></h2>
</div>
<?php }