Custom Post Type Archive Permalinks (3 posts)

  1. neil.mills
    Posted 3 years ago #

    I have successfully managed to set up a custom post type with:

    add_action( 'init', 'create_news_post_type' );
    function create_news_post_type() {
     register_post_type( 'news', array(
    		'labels' => array(
    			'name' => __('News'),
    			'singular_name' => __('Article')
    		'public' => true,
    		'show_ui' => true,
    		'rewrite' => array(
    		'slug' => 'news',
    		'with_front' => false
    		'has_archive' => true
    	) );

    This code sets up my archive page at http://www.mydomain/news which displays the template page archive-news.php

    Within this page i have:

    <h2>news archive page</h2>
    <? wp_get_post_type_archives('news', array('type' => 'monthly', 'show_post_count' => true)); ?>
    while (have_posts()) : the_post();
    echo the_title();

    Which outputs my posts and monthly archive menu fine.
    I have used the function wp_get_post_type_archives from the Custom Post Type Archives plugin which outputs ok

    The issue i have is that the permalinks from the archive menu links are giving me a 404 error.
    The link for February 2012 is http://www.mydomain.co.uk/book/2012/02

    I cant work out what the issue is? Obviously something with my Permalink or a Custom Post Type Archives config issue.

    Has anyone had a similar issue and resolved it?

    Many thanks

  2. FranklynJones
    Posted 3 years ago #

    I'm having exactly the same issue with this, I've been trying to chase this issue down and nobody can seem to resolve it.

    If you do, please let me know,


  3. baxang
    Posted 3 years ago #


    I had exactly the same issue and figured out that what the plugin relies on is changed by the other plugin. I'm using CCTM(http://wordpress.org/extend/plugins/custom-content-type-manager/) and this plugin changes $where into another format which PTA cannot handle.

    If you want a quick but fragile solution, open up post-type-archive.php in the plugin directory and change
    add_filter('getarchives_where', 'pta_wp_get_archives_filter', 10, 2);
    add_filter('getarchives_where', 'pta_wp_get_archives_filter', 9, 2);
    (just change the priority from 10 to 9).

Topic Closed

This topic has been closed to new replies.

About this Topic