spencer-f
4/7/2015 - 4:15 PM

Create And Display List Of Custom Post Types (excluding sticky posts) (see: https://1wd.tv/wordpress-sticky-posts-and-custom-wp-queries/)

Create And Display List Of Custom Post Types (excluding sticky posts) (see: https://1wd.tv/wordpress-sticky-posts-and-custom-wp-queries/)

// Code To Display Sticky Posts For All Custom Post Types
function lab_latest_sticky_all() { 
                $args = array(
                'post__in' => get_option( 'sticky_posts' ),
                'showposts' => 4,
                'post_type' => array ('download','post', 'page', 'latest', 'topic', 'forum', 'webinars', 'hangouts', 'lessons', 'kits'),
                'ignore_sticky_posts' => 1
                );
                $the_query = new WP_Query( $args );
                while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
                <li><i class="fa fa-play-circle"></i><a title="<?php  the_title(); ?>" href="<?php  the_permalink()  ?>" rel="bookmark"><?php  the_title(); ?></a></li>
                <?php 
	endwhile;
	wp_reset_postdata();
}
add_shortcode('latest_sticky_all', 'lab_latest_sticky_all');

// Code To Use to Display the Sticky Post Query Shown above (use in a template file)
<h1>Latest QuickTips</h1>
  		      <ul>
        			<?php
	$args = array( 'numberposts' => 4 );
	$recent_posts = wp_get_recent_posts( $args );
	foreach( $recent_posts as $recent ){
		echo '<li><i class="fa fa-play-circle"></i><a href="' . get_permalink($recent["ID"]) . '">' .   $recent["post_title"].'</a> </li> ';
	}

	?>
  		      </ul>