Reputation: 1
The problem: our WordPress installation is using archive.php for an archive page instead of the desired archive-article.php.
Here is our configuration:
functions.php
register_post_type(
'article',
array(
'labels' => array(
'name' => __('Articles'),
'singular_name' => __('Article'),
),
'public' => true,
'has_archive' => true,
'menu_icon' => 'dashicons-media-default',
'menu_position' => 4,
'taxonomies' => array('article_type'),
'supports' => array('title', 'editor', 'custom-fields', 'page-attributes', 'thumbnail')
)
);
archive-article.php
<?php
/**
* The template for displaying Archive pages.
*
* Used to display archive-type pages if nothing more specific matches a query.
* For example, puts together date-based pages if no date.php file exists.
*
* Learn more: http://codex.wordpress.org/Template_Hierarchy
*
* Methods for TimberHelper can be found in the /lib sub-directory
*
* @package WordPress
* @subpackage Timber
* @since Timber 0.2
*/
$templates = array( 'archive-article.twig', 'index.twig' );
$context = Timber::context();
$args = array(
'post_type' => 'article',
'posts_per_page' => '-1'
);
$context['title'] = 'Archive: Article';
$context['categories'] = $post->terms( array(
'query' => [
'taxonomy' => 'article_type',
],
) );
$context['article'] = new \Timber\PostQuery($args);
Timber::render( $templates, $context );
Any help from a second pair of eyes would be greatly appreciated!
Upvotes: 0
Views: 1319
Reputation: 1126
Try adding the archive slug to you custom post regisration, in addition to has_archive?
"rewrite" => array("slug" => "articles"),
Upvotes: 1