WP不同类别调用不同文件

留着以后备用,准备着手制作一个CMS主题。

 
<?php
$post = $wp_query->post;
if ( in_category(‘7’) ) {
include(TEMPLATEPATH . ‘/archive-view.php’);
}
else if ( in_category(’12’) ) {
include(TEMPLATEPATH . ‘/single12.php’);
}
else if ( in_category(’42’) ) {
include(TEMPLATEPATH . ‘/single42.php’);
}
else {
include(TEMPLATEPATH . ‘/archive-other.php’);
}
?>

<?php
$post = $wp_query->post;
if ( in_category(‘7’) ) {
include(TEMPLATEPATH . ‘/single-view.php’);
}
else if ( in_category(‘3’)) {
include(TEMPLATEPATH . ‘/single-case.php’);
}
else if ( in_category(’42’) ) {
include(TEMPLATEPATH . ‘/single42.php’);
}
else {
include(TEMPLATEPATH . ‘/archive-other.php’);
}
?>

<?php $posts = get_posts( “category=4&numberposts=10″ ); ?>
<?php if( $posts ) : ?>
<ul><?php foreach( $posts as $post ) : setup_postdata( $post ); ?>
    <li>
        <a href=”<?php the_permalink() ?>” rel=”bookmark” title=”<?php the_title(); ?>”><?php the_title(); ?></a>
    < >
    <?php endforeach; ?>
</ul>
<?php endif; ?>

赞 (0)
分享到:更多 ()