Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm making a custom post type that I want to use in the form of a plugin - all pretty straight forward.

However, I want the archive page for this post type to look slightly different in the content area - how would I achieve this without having to ask the end user to move files to their template directory?

I hope that makes sense, if not please ask me to clarify further - I've not really been able to find anything in the codex, but maybe I'm looking in the wrong place.

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

Use archive_template filter in your plugin to override archive templates for a given post type, for example, movies:

<?php
function get_movies_archive_template( $archive_template ) {
     global $post;
     if ( is_post_type_archive ( 'movies' ) ) {
          $archive_template = dirname( __FILE__ ) . '/templates/movies-archive-template.php';
     }
     return $archive_template;
}
add_filter( 'archive_template', 'get_movies_archive_template' ) ;

See archive_template in Codex.

share|improve this answer
    
Looks like what I need - thanks! so I would make a custom file with a structure like get header - my custom content - get footer? –  user319940 Mar 15 '13 at 11:38
    
Yes, that's right. It have to be the regular WP template. –  Max Yudin Mar 15 '13 at 11:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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