Skip to content

Instantly share code, notes, and snippets.

@nickkuijpers
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickkuijpers/3373ad72a79f3743c365 to your computer and use it in GitHub Desktop.
Save nickkuijpers/3373ad72a79f3743c365 to your computer and use it in GitHub Desktop.
Wordpress: Get Custom Posts
<?php
$loop = new WP_Query(
array(
'post_type' => 'posts',
'posts_per_page' => 9999
)
);
$i = 0;
while ( $loop->have_posts() ) : $loop->the_post();
$i++;
$id = get_the_ID();
?>
<?php
$terms = get_terms( 'type' );
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){
foreach ( $terms as $term ) {
?>
<?php echo sanitize_title($term->name); ?>
<?php echo $term->name; ?>
<?php
}
}
?>
<?php
$image = '';
if (has_post_thumbnail()) {
$image = get_the_post_thumbnail($id,'large', array('class' => 'img-responsive'));
}
?>
<?php the_title(); ?>
<?php the_content(); ?>
<?php
endwhile;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment