1
votes

I have made a custom category template using category-[id].php and it's fine now. All i am trying to do is to add a Jquery Post slider with featured images on custom category page. Currently, my theme allows me to add this to home page. Currently, i have defined a category in my theme admin panel for this slider.

My homepage has a slider for category "Featured" . How can i have such type of slider on my Custom Category Template page showing recent 4 or 5 posts from that category [different from the home page one] with "Featured Images" ? Can i use the same Featured slider function of my theme to have a new slider as i described on my custom category template page ?

** My Wordpress theme is LondonLive by Skyli.

index.php code:

<?php get_header(); ?>

<?php if( get_option('skyali_londonlive_featured_style') != 'slider_long' AND  get_option('skyali_londonlive_featured_style') != ''){ ?>

<?php  if($video_ != 'true'){  ?>

<?php include_once('includes/'.display_featured().'.php'); // include featured ?>

<?php } else { ?>

<?php include_once('includes/featured_2.php'); } ?>

<?php } ?>

<?php if(get_option('skyali_londonlive_slider') != '' && get_option('skyali_londonlive_slider') != 'disable'){ ?>

<?php include_once('includes/slider.php'); ?>
..........

Featured Slider Code:

<div id="featured" <?php featured_option(); ?>>
<?php  $featured_cat = get_option('skyali_londonlive_featured_cats'); //get featured category ?>
<ul class="ui-tabs-nav">
<?php $i = 1; ?>
<?php
//list featured slide previews
$featured = new WP_Query('showposts=4&cat='.$featured_cat.''); while($featured->have_posts()) : $featured->the_post(); ?>
<?php if($i == 1){$select_element = 'ui-tabs-selected';} else { $select_element = ''; } ?>
.........
//list featured slide show div's 
$featured = new WP_Query('showposts=4&cat='.$featured_cat.''); while($featured->have_posts()) : $featured->the_post(); ?>
<!-- <?php echo $i; ?> Content -->
1

1 Answers

1
votes

You should be able to copy/paste most of the code you need from the index.php file for your theme. Its not a freely available theme so I can't look at that code myself, but if you look for <div id="featured"> it should get you pretty close.

Then you'll just need to modify the query being performed in that code to limit it to just the category that you want. If it's using get_posts, then your query would look something like this:

$current_category = single_cat_title("", false);
$args = array(
    'numberposts'     => 5,
    'offset'          => 0,
    'category_name'   => $current_category,
    'orderby'         => 'post_date',
    'order'           => 'DESC',
    'post_type'       => 'post',
    'post_status'     => 'publish' );

$recent_posts = get_posts( $args );

If it's using WP_Query, your query should look something like this:

$current_category = single_cat_title("", false);
$cat_posts = new WP_Query('showposts=5&category_name='.$current_category);

while ($cat_posts->have_posts())

...