Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Slider adjustment WordPress

  • SOLVED

I have a php template for the homepage, but I want to reuse it for another page. The slider calls a post that has been assigned to a category.

<?php
/*
Template Name: Home Template
*/
get_header(); ?>
<div id="main">
<div class="intro">
<?php query_posts('cat='.sliderCategoryID.'&showposts=10');?>
<?php if (have_posts()) : ?>
<div class="gallery-holder carousel">
<div class="gallery">
<div class="gholder">
<div class="gmask">
<ul>
<?php while (have_posts()) : the_post(); ?>
<li>
<?php if(has_post_thumbnail()): ?>
<?php the_post_thumbnail('slider-home-thumbnail');?>
<?php endif;?>
<div class="text">
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<div class="inner">
<?php the_excerpt();?>
</div>
</div>
</li>
<?php endwhile;?>
</ul>
</div>
</div>
</div>
<span class="mask"></span>
</div>
<?php endif; wp_reset_query(); ?>
<?php if (is_active_sidebar('car-loan-contact')) : ?>
<?php dynamic_sidebar('car-loan-contact'); ?>
<?php endif; ?>
</div>
<?php $sub_pages = get_pages(array('child_of' => $post->ID, 'sort_column' => 'menu_order','parent'=>$post->ID,'number'));?>
<?php if($sub_pages): ?>
<div class="items">
<div class="inner">
<?php foreach ( $sub_pages as $page ) : ?>
<?php $page_data = get_page( $page->ID ) ?>
<div class="item">
<?php if(get_the_post_thumbnail($page->ID)):?>
<?php echo get_the_post_thumbnail($page->ID,'subpage-home-thumbnail')?>
<?php endif;?>
<h2><a href="<?php echo get_permalink($page->ID );?>"><?php echo $page_data->post_title; ?></a></h2>
<?php echo apply_filters('the_excerpt', $page_data->post_excerpt);?>
<div class="more">
<a href="<?php echo get_permalink($page->ID );?>" title="Learn more">Learn more</a>
</div>
</div>
<?php endforeach;?>
</div>
</div>
<?php endif;?>
</div>
<?php get_footer(); ?>

Answers (1)

2012-06-13

S├ębastien | French WordpressDesigner answers:

if you want to use this template for another page, the page "society" for example, you must choose the template "Home Template" in the edition of the page "society".

If you want that the page "society" use this slider with another category (for example the category which have the ID = 8) you must replace
<?php query_posts('cat='.sliderCategoryID.'&showposts=10');?>
by
<?php query_posts('cat=8'&showposts=10');?>
and replace
Template Name: Home Template
by
Template Name: Society Template
and save the file as "society.php" in your theme folder
and you must choose the template "Society Template" in the edition of the page "society".

Is it clear ?


Greg Ellett comments:

this worked perfect, except now the new templates, society.php are pulling in the posts under that both home.php and society.php.

odd