Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function featured_posts_YIW($args = null) {
- global $featured_post_plugin_path;
- $defaults = array(
- 'title' => 'Featured Posts',
- 'numberposts' => 5,
- 'orderby' => 'DESC',
- 'widththumb' => 73,
- 'heightthumb' => 73,
- 'beforetitle' => '<h3>',
- 'aftertitle' => '</h3>',
- 'show' => 'featured',
- 'category' => 'uncategorized'
- );
- /**
- * Merging default values with user selected settings
- */
- $fp = wp_parse_args($args, $defaults);
- $title = $fp['title'];
- $showposts = $fp['numberposts'];
- $orderby = $fp['orderby'];
- $width_thumb = $fp['widththumb'];
- $height_thumb = $fp['heightthumb'];
- $before_title = $fp['beforetitle'];
- $after_title = $fp['aftertitle'];
- $show = $fp['show'];
- $cat_ID = $fp['category'];
- /* List's title */
- if ( !empty($title) ) {
- echo $before_title . $title . $after_title;
- }
- /*
- * Modificare i parametri di questa query per mostrare/escludere
- * categorie, pagine.
- * If you want to exclude categories and/or pages modify this query
- * properly
- * Info: http://codex.wordpress.org/Template_Tags/get_posts
- *
- * @todo Aggiungere esempio per mostrare/escludere categorie e pagine in
- * questo commento
- */
- global $post;
- if ( (strcmp($show, 'category') == 0 ) && ($cat_ID)) {
- $get_posts_query = 'category=' . $cat_ID;
- $get_posts_query .= '&numberposts=' . $showposts;
- $get_posts_query .= '&orderby=' . $orderby;
- } else {
- $get_posts_query = 'meta_key=featured&meta_value=1';
- $get_posts_query .= '&numberposts=' . $showposts;
- $get_posts_query .= '&orderby=' . $orderby;
- }
- $featured_posts = get_posts($get_posts_query);
- echo '<ul id="yiw-featured-post">';
- foreach ($featured_posts as $post):
- setup_postdata($post);
- ?>
- <li>
- <a href="<?php the_permalink() ?>" class="featured-thumb">
- <?php if ( (function_exists('the_post_thumbnail')) && (has_post_thumbnail()) ) :
- $image = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full' ); ?>
- <img src="<?php echo $featured_post_plugin_path ?>scripts/timthumb.php?src=<?php echo $image[0] ?>&h=<?php echo $height_thumb ?>&w=<?php echo $width_thumb ?>&zc=1" class="alignleft" alt="<?php the_title(); ?>" />
- <?php else : ?>
- <img src="<?php echo $featured_post_plugin_path ?>scripts/timthumb.php?src=<?php echo catch_that_image() ?>&h=<?php echo $height_thumb ?>&w=<?php echo $width_thumb ?>&zc=1" class="alignleft" alt="<?php the_title(); ?>" />
- <?php endif; ?>
- </a>
- <h4 class="featured-title">
- <a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
- </h4>
- </li>
- <?php
- endforeach;
- echo "</ul>";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement