首页 文章

在wordpress上的自定义类别页面模板上添加Jquery Post滑块?

提问于
浏览
1

我使用category- [id] .php创建了一个自定义类别模板,现在很好 . 我想要做的就是在自定义类别页面上添加一个带有特色图像的Jquery Post滑块 . 目前,我的主题允许我将其添加到主页 . 目前,我已在我的主题管理面板中为此滑块定义了一个类别 .

我的主页有一个“特色”类别的滑块 . 如何在我的自定义类别模板页面上显示此类滑块,显示该类别[与主页1不同]的最近4或5个帖子带有“精选图像”?我可以使用与我的主题相同的精选滑块功能来创建我在自定义类别模板页面上描述的新滑块吗?

**我的Wordpress主题是Skyli的LondonLive .

index.php代码:

<?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'); ?>
..........

精选滑块代码:

<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

    您应该能够从index.php文件中为您的主题复制/粘贴您需要的大部分代码 . 它不是一个免费的主题,所以我不能自己查看代码,但是如果你寻找 <div id="featured"> 它应该让你非常接近 .

    然后你'll just need to modify the query being performed in that code to limit it to just the category that you want. If it'使用 get_posts ,然后你的查询看起来像这样:

    $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 );
    

    如果它使用WP_Query,您的查询应该如下所示:

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

相关问题