Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I was wondering to know if it's possible to use global posts with custom_types. I was working with this function:

global $post; 
$myposts = get_posts('numberposts=4&offset=1& category=3,4'); 
foreach($myposts as $post) : 
    setup_postdata($post); ?>
    <a href="<?php the_permalink() ?>" rel="bookmark" title="Visualizza <?php the_title(); ?>"><img src="<?php echo get_option('home'); ?>/wp-content/uploads/posthumb/<?php $values = get_post_custom_values("Image"); echo $values[0]; ?>" alt="<?php the_title(); ?>" /></a>
<?php endforeach;

As soon as I've moved the post from the standard articles type to a new custom post type, this stopped working. The category is still the same. Can I get it work again in any kind of way?

Thank you very much for your reply.

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

By default get_posts() uses a default post type of post.

If you want to select from a CPT then you need this:

$myposts = get_posts('numberposts=4&offset=1&category=3,4&post_type=YOUr_CPT_HERE');
share|improve this answer
    
Thanks Brady! I was going crazy trying to find that option!!! Thank you so much!!! –  FrA Sep 11 '12 at 13:01
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.