У меня есть необъяснимая проблема со страницей нестандартного типа поста (в данном случае новостными статьями), не поднимающей ее единственную {custom} .php-страницу.Это важно сделать, так как он содержит пользовательские поля (из ACF) для правильного отображения с названием, автором, издателем и датой для статей или исследований, которые были первоначально опубликованы.
Странно, что естьдругие страницы CPT, все четыре вместе, которые работают как нужно, статьи на первой странице (fparticle), новостные статьи (статьи), исследования (исследования) и еще одна, называемая MikeSays (майксы).
Вот страница CPT, котораяЯ звоню из папки mu-plugins:
<?php
/*
* Theme Name: three-strikes-v3
*
* Layout: Three Strikes Post Types Page
*
* Learn more: https://developer.wordpress.org/themes/basics/template-files/
*/
function threestrikes_post_types() {
// Custom Post Type - Front Page Articles
register_post_type('fparticle', array(
'supports' => array('title', 'editor', 'excerpt', 'thumbnail'),
'rewrite' => array('slug' => 'fparticle'),
'has_archive' => true,
'public' => true,
'labels' => array(
'name' => 'New FP Article',
'add_new_item' => 'Add New FP Article',
'edit_item' => 'Edit FP Article',
'all_items' => 'All FP Articles',
'singular_name' => 'FP Article',
),
'menu_icon' => 'dashicons-admin-home',
));
// Custom Post Type - News Articles Post Type
register_post_type('article', array(
'supports' => array('title', 'editor', 'excerpt', 'thumbnail'),
'rewrite' => array('slug' => 'articles'),
'has_archive' => true,
'public' => true,
'labels' => array(
'name' => 'News Articles',
'add_new_item' => 'Add New Article',
'edit_item' => 'Edit Article',
'all_items' => 'All Articles',
'singular_name' => 'Article',
),
'menu_icon' => 'dashicons-admin-page',
));
// Custom Post Type - Studies Post Type
register_post_type('study', array(
'supports' => array('title', 'editor', 'excerpt', 'thumbnail'),
'rewrite' => array('slug' => 'studies'),
'has_archive' => true,
'public' => true,
'labels' => array(
'name' => 'Studies Page',
'add_new_item' => 'Add New Study',
'edit_item' => 'Edit Study',
'all_items' => 'All Studies',
'singular_name' => 'Study',
),
'menu_icon' => 'dashicons-admin-customizer',
));
// Custom Post Type - Mike's Commentaries
// Studies Post Type
register_post_type('mikesays', array(
'supports' => array('title', 'editor', 'excerpt', 'thumbnail'),
'rewrite' => array('slug' => 'mikesays'),
'has_archive' => true,
'public' => true,
'labels' => array(
'name' => 'Mike Says',
'add_new_item' => 'Add New Mike Says',
'edit_item' => 'Edit Mike Says',
'all_items' => 'All Mike Says',
'singular_name' => 'Mike Says',
),
'menu_icon' => 'dashicons-id-alt',
));
}
add_action('init', 'threestrikes_post_types');
Это то же самое, что я узнал от Удеми.
Когда впервые столкнулся с проблемой, я использовал один из рабочих пользовательских типов постов.страниц, Front Page Articles, так как это работало как другие сразу.Я заменил Расширенные пользовательские поля со страницы fparticles на ACF для страницы «статьи».Он по-прежнему НЕ будет воспринимать визуализацию страницы single-news-article.php, как задумано.
Следовательно, я в тупике.Я просмотрел все другие ссылки на этом сайте, похожие на ту же проблему, и ни один совет не работал для меня.
Код статей новостей:
<?php
/**
* The template for displaying all News Article pages
*
* This is the template that displays all pages by default.
* Please note that this is the WordPress construct of pages
* and that other 'pages' on your WordPress site may use a
* different template.
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*
* @package threestrikesv3
*/
get_header();
?>
<section id="news">
<div class="container">
<h2>News Articles on 3 Strikes</h2>
<h5 class="h5-spacer">We have a collection of news articles, generally supporting 3 Strikes,
from major publishers throughout America since 3 Strikes' overwhelming passage
by California voters in 1994.</h5>
<hr>
</div><!-- .container //-->
</section>
<div class="container">
<div class="row">
<div id="primary" class="content-area col-md-8">
<main id="main" class="main">
<?php
$newspagePosts = new WP_Query(array(
'paged' => get_query_var('paged'),
'posts_per_page' => 8,
'post_type' => 'article',
'meta_key' => 'news_article_date',
'orderby' => 'meta_value_num',
'order' => 'ASC'
)); ?>
<?php
while ($newspagePosts->have_posts()) {
$newspagePosts->the_post(); ?>
<article class="post">
<h3><a href="<?php the_permalink(); ?>"><?php
the_field('news_article_title'); ?></a></h3>
<div class="publisher-meta">
<p>Published by: <?php the_field('news_article_publisher'); ?>
</p>
<p>Written by <a href="<?php echo
get_author_posts_url(get_the_author_meta('ID')); ?>"><?php
the_field('news_article_author'); ?></a> on <?php
the_field('news_article_date'); ?> in <?php echo get_the_category_list(',
');
?>
</p>
</div>
<div class="content-meta">
<?php echo get_the_excerpt(); ?>
<p><a href="<?php the_permalink(); ?>">Continue reading ...
</a></p>
<hr>
</div>
<?php } ?>
<?php echo paginate_links(array(
'total' => $newspagePosts->max_num_pages
));
wp_reset_postdata(); ?>
</article>
</main><!-- #main -->
</div><!-- #primary .col-md-8 -->
<div class="col-md-4 ts-sidebar">
<?php get_sidebar(); ?>
</div>
</div><!-- .row //-->
</div><!-- .container //-->
<?php
get_footer();
Ранее Wordpress использовал бы single.php
, но сейчас этим не занимаюсь.Прошло несколько дней, поэтому я забыл, что я сделал, чтобы вызвать это.
TIA, Дейв, он же Гарри Уильямс.