Advertisement
Guest User

WP: Featured-Posts-With-Thumbnail Plugin Workaround (1.5.1)

a guest
Sep 8th, 2012
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.72 KB | None | 0 0
  1. function featured_posts_YIW($args = null) {
  2.  
  3.     global $featured_post_plugin_path;
  4.     $defaults = array(
  5.          'title' => 'Featured Posts',
  6.          'numberposts' => 5,
  7.          'orderby' => 'DESC',
  8.          'widththumb' => 73,
  9.          'heightthumb' => 73,
  10.          'beforetitle' => '<h3>',
  11.          'aftertitle' => '</h3>',
  12.          'show' => 'featured',
  13.          'category' => 'uncategorized'
  14.     );
  15.  
  16.     /**
  17.      *  Merging default values with user selected settings
  18.      */
  19.     $fp = wp_parse_args($args, $defaults);
  20.     $title = $fp['title'];
  21.     $showposts = $fp['numberposts'];
  22.     $orderby = $fp['orderby'];
  23.     $width_thumb = $fp['widththumb'];
  24.     $height_thumb = $fp['heightthumb'];
  25.     $before_title = $fp['beforetitle'];
  26.     $after_title = $fp['aftertitle'];
  27.     $show = $fp['show'];
  28.     $cat_ID = $fp['category'];
  29.  
  30.     /* List's title */
  31.     if ( !empty($title) ) {
  32.         echo $before_title . $title . $after_title;
  33.     }
  34.  
  35.     /*
  36.      * Modificare i parametri di questa query per mostrare/escludere
  37.      * categorie, pagine.
  38.      * If you want to exclude categories and/or pages modify this query
  39.      * properly
  40.      * Info: http://codex.wordpress.org/Template_Tags/get_posts
  41.      *
  42.      * @todo Aggiungere esempio per mostrare/escludere categorie e pagine in
  43.      * questo commento
  44.      */
  45.     global $post;
  46.     if ( (strcmp($show, 'category') == 0 ) && ($cat_ID)) {
  47.         $get_posts_query = 'category=' . $cat_ID;
  48.         $get_posts_query .= '&numberposts=' . $showposts;
  49.         $get_posts_query .= '&orderby=' . $orderby;
  50.     } else {
  51.         $get_posts_query = 'meta_key=featured&meta_value=1';
  52.         $get_posts_query .= '&numberposts=' . $showposts;
  53.         $get_posts_query .= '&orderby=' . $orderby;
  54.     }
  55.     $featured_posts = get_posts($get_posts_query);
  56.  
  57.     echo '<ul id="yiw-featured-post">';
  58.     foreach ($featured_posts as $post):
  59.         setup_postdata($post);
  60.         ?>
  61.        <li>
  62.            <a href="<?php the_permalink() ?>" class="featured-thumb">
  63.            <?php if ( (function_exists('the_post_thumbnail')) && (has_post_thumbnail()) ) :
  64.                $image = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full' ); ?>
  65.                <img src="<?php echo $featured_post_plugin_path ?>scripts/timthumb.php?src=<?php echo $image[0] ?>&amp;h=<?php echo $height_thumb ?>&amp;w=<?php echo $width_thumb ?>&amp;zc=1" class="alignleft" alt="<?php the_title(); ?>" />
  66.            
  67.            <?php else : ?>
  68.                <img src="<?php echo $featured_post_plugin_path ?>scripts/timthumb.php?src=<?php echo catch_that_image() ?>&amp;h=<?php echo $height_thumb ?>&amp;w=<?php echo $width_thumb ?>&amp;zc=1" class="alignleft" alt="<?php the_title(); ?>" />
  69.            <?php endif; ?>
  70.            </a>
  71.            
  72.            <h4 class="featured-title">
  73.                <a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
  74.            </h4>
  75.        </li>
  76.     <?php
  77.        endforeach;
  78.        echo "</ul>";
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement