Hooking in to an archive page?

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?

Read More

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.

Related posts

Leave a Reply

1 comment

  1. 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 ) {
         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.