0

I'm having very weird issues with my permalinks and template files on this site I'm building.

I've created several Custom Post Types. These all have archive pages in my template structure named archive-$posttype.php I've also created custom page templates named page-$name.php that's located in a folder named my-templates.

Here's my issue. When using default permalink settings these pages all work perfectly, but when prettyfying the permalink to /%postname%/ or any other permalink setting but the default one, they stop working and default to the index template.

I know there's nothing wrong with my code for the CPT as they all have set archive

'rewrite'   => array( 'slug' => 'publikasjoner', 'with_front' => false ),
'has_archive' => 'publikasjoner',

There must be something I'm missing somewhere, but I've never had this issue and I can't find any info on it elsewhere..

3
  • post type archive templates should be named archive-$posttype.php
    – Milo
    Commented Jan 22, 2015 at 19:36
  • Sorry, corrected that in the question. My templates are named archive-$posttype.php Commented Jan 22, 2015 at 19:43
  • Are you sure you have no conflicts with other plugins or functions? Test your CPT archive on clean WordPress install with default theme.
    – Alexey
    Commented Jan 23, 2015 at 0:49

1 Answer 1

0

I'd try two things first:

  1. Make sure you have flushed the permalinks ( Settings - Permalinks - Update )
  2. Make sure you are using an init action hook to create your custom post types (I've forgotten to do this before and had the type of issue you describe)

If that fails, I'd recommend updating your question to include the full declaration of at least one of your custom post types and show the action you are using to set it up.

2
  • Is there a way for me to manually flush the permalinks? Updating from settings doesn't seem to update it. When visiting /?post_type=publikasjoner after updating permalinks to /%postname%/.. Commented Jan 23, 2015 at 11:51
  • If you've went into settings - permalinks and selected update, then you should be good on that front. That effectively flushes them manually. If that didn't help, try item (2) noted above.
    – Privateer
    Commented Jan 24, 2015 at 18:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.