Browse Source

sticky posts conditional

windhamdavid 4 years ago
parent
commit
114655a2f6
1 changed files with 9 additions and 5 deletions
  1. 9 5
      page-desk.php

+ 9 - 5
page-desk.php

@@ -22,12 +22,16 @@ get_header(); ?>
 			</div>
 			<div class="col-md-4 studio-tools">
 				<ul>
-					<li>Recently Edited</li>
-          <?php $args = array('post_type' => 'post','posts_per_page' => 5,'post__in' => get_option('sticky_posts'));?>
-					<?php $stickyposts = get_posts($args); foreach ($stickyposts as $post) : setup_postdata($post); ?>
-					       <li style="color:#777"><?php echo get_the_date('m/d/y'); ?> - <a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
-					<?php endforeach; ?>
+          <?php $sticky = get_option('sticky_posts');?>
+          <?php if( !empty($sticky) ){ ?>
+          <?php $args = array('post_type' => 'post','posts_per_page' => 5,'post__in' => $sticky);?>
+					<?php $stickyposts = get_posts($args); ?>
+            <li>Recently Edited</li>
+            <?php foreach ($stickyposts as $post) : setup_postdata($post); ?>
+              <li style="color:#777"><?php echo get_the_date('m/d/y'); ?> - <a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
+					  <?php endforeach; ?>
           <br>
+          <?php } ?>
 					<li>Recent Posts</li>
 					<?php $recentposts = get_posts('numberposts=54'); foreach ($recentposts as $post) : setup_postdata($post); ?>
 					       <li style="color:#777"><?php echo get_the_date('m/d/y'); ?> - <a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>