get_posts() returns wrong custom post type
-
So I got a problem here.
This code is for some kind of an image slider, displaying one post type’s posts at the top of the page. The exact same code works on my development site (same server etc.). I’ve set up a new installation (same version of WP) and created two posts of another (custom) post type first, then a post of the post type, named myposttype here.
I now get the two posts of the other custom post type displayed in my image slider, instead of the post of post type myposttype.
<? $myposts = get_posts( array( 'post_type' => 'myposttype' ) ); if( $myposts ) : ?> <div class="list_carousel_wrapper"> <div class="list_carousel responsive clear"> <ul id="slider"> <? foreach($myposts as $mypost) : ?> <li> <a href="<?=get_permalink($mypost->ID);?>" title="<?=$mypost->post_title;?>"> <div class="imgcontainer"><div class="imgvignette"><img src="<? echo wp_get_attachment_url( get_post_thumbnail_id( (int) $mypost->ID ) ); ?>"></div></div> <div class="vignette"><h4><? echo (empty($mypost->ashortname)) ? $mypost->post_title : $mypost->ashortname; ?></h4><p><? echo $mypost->ateaser; ?></p></div> </a> </li> <? endforeach; ?> </ul> </div> </div> <? endif; ?>
Can anyone help me here? Thanks a bunch!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘get_posts() returns wrong custom post type’ is closed to new replies.