admin管理员组文章数量:1294722
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.
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 asked Mar 15, 2013 at 11:12 user319940user319940 5762 gold badges5 silver badges17 bronze badges1 Answer
Reset to default 2Use 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.
本文标签: custom post typesHooking in to an archive page
版权声明:本文标题:custom post types - Hooking in to an archive page? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741605761a2387964.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论