Plugin Directory

Changeset 551510


Ignore:
Timestamp:
05/31/2012 06:41:44 PM (14 years ago)
Author:
leethompson
Message:

Refactored to not show the div if no thumbnail-enabled posts are found -
tgarrison

Location:
lazy-content-slider/tags/2.1
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lazy-content-slider/tags/2.1/lzcs.php

    r551450 r551510  
    55Description: This is a content slider that shows 5 slides from a "Featured Category"                                                                                               
    66Author: Lee Thompson                                                                                                                                                               
    7 Version: 2.1
     7Version: 2.2
    88Author URI: http://mysqlhow2.com                                                                                                                                                   
    99                                                                                                                                                                                   
     
    9090}
    9191
    92 function drawslider() {
    93     global $post;
    94     echo "<div id=\"featured\" >";
    95     echo "<ul class=\"ui-tabs-nav\">";
     92function getDisplayPosts($limit = 4)
     93{
    9694    $posts = get_option('lzcs_cat');
    9795    $args = array('category' => $posts );
    9896    $recent_posts = wp_get_recent_posts( $args );
    99    
    100     $limit = 4;
    101     $displayedPosts = 0;
    102    
     97
     98    $output = array();
     99    foreach ($recent_posts as $post) {
     100        setup_postdata($post);
     101        if (has_post_thumbnail($post['ID'])) {
     102            $output[] = $post;
     103        }
     104
     105        if (count($output) > $limit) break;
     106    }
     107
     108    return $output;
     109}
     110
     111function drawslider() {
     112    global $post;
     113    $recent_posts = getDisplayPosts();
     114
     115    if (count($recent_posts) == 0) {
     116        return;
     117    }
     118
     119    echo "<div id=\"featured\" >";
     120    echo "<ul class=\"ui-tabs-nav\">";
     121
    103122    foreach( $recent_posts as $recent ){
    104123        setup_postdata($recent);
    105124        $postid = $recent["ID"];
    106         if (!has_post_thumbnail($postid)) {
    107                 continue;
    108         }
    109        
    110         if (++$displayedPosts > $limit) break;
    111        
     125
    112126        $thumbnail =  get_the_post_thumbnail( $postid, array(50, 50) );
    113127       
     
    124138    echo '</ul>';   // Closing the div.ui-tabs-nav
    125139   
    126     $displayedPosts = 0;
    127            
     140
    128141    foreach( $recent_posts as $recent ){
    129142        $postid = $recent["ID"];
     
    132145        $postexcerpt = string_limit_words($postexcerpt,15);
    133146
    134         if (!has_post_thumbnail($postid)) {
    135                 continue;
    136         }
    137        
    138         if (++$displayedPosts > $limit) break;
    139        
    140147        $largeimage = get_the_post_thumbnail( $postid, array(400, 250));
    141148?>                     
  • lazy-content-slider/tags/2.1/readme.txt

    r551450 r551510  
    55Requires at least: 2.9.2
    66Tested up to: 3.3.2
    7 Stable tag: 2.1
     7Stable tag: 2.2
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    5151
    5252== Frequently Asked Questions ==
    53 Just want to give shout out to Tim Garrison who helped with my looping and
     53Just want to give shout out to Tim Garrison [http://www.skudd.com/] who helped with my looping and
    5454webdeveloperplus with the great tutorial on the slider using jquery.
    5555
     
    7171= 2.1 =
    7272Added Excerpt to div.info
     73= 2.2 =
     74Refactored to not show the div if no thumbnail-enabled posts are found -
     75tgarrison
    7376
    7477
     
    8992= 2.1 =
    9093Added Excerpt to div.info
     94= 2.2 =
     95Refactored to not show the div if no thumbnail-enabled posts are found -
     96tgarrison
     97
Note: See TracChangeset for help on using the changeset viewer.