Advertisement
FriendlyWP

Highlights function

Aug 1st, 2011
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.21 KB | None | 0 0
  1. function display_highlights($_category_slug = 'research-highlights', $_count_posts = 3)
  2. {
  3.     $my_cat = get_category_by_slug($_category_slug);
  4.     $highlights_query = new WP_Query('orderby=date&order=DESC&showposts='.$_count_posts.'&cat='.@$my_cat->term_id);
  5.     if ($my_cat):
  6.     ?>
  7.         <div class="research-highlights">
  8.             <h3><a href="<?php echo get_category_link($my_cat->term_id); ?>"><?php print $my_cat->name; ?></a></h3>
  9.     <?php
  10.     if ($highlights_query->have_posts()):
  11.         ?>
  12.             <ul>
  13.                 <?php while ($highlights_query->have_posts()) :
  14.                     $highlights_query->the_post();
  15.                     global $post;
  16.                     ?>
  17.                     <li>
  18.                         <div class="txt">
  19.                             <p><a class="read-more-title-link" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></p>
  20.                         </div>
  21.                     </li>
  22.                 <?php endwhile; ?>
  23.             </ul>
  24.             <a class="lnk-more" href="<?php echo get_category_link($my_cat->term_id); ?>">more</a>
  25.     <?php else: ?> <p>There are no <?php print $my_cat->name; ?> at this time.</p><p>Please check back again soon.</p>
  26.     <?php
  27.     endif;
  28.      ?>
  29.         </div>
  30. <?php else: ?> <div class="research-highlights"><h3><?php print $my_cat->name; ?></h3><p>The category name has been changed. Please change back to restore feed.</p></div>
  31. <?php endif;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement