Link to home
Start Free TrialLog in
Avatar of cstela
cstela

asked on

How to get custom post type title, excerpt, thumbnail and permalink by post ID?

Hi there,
I have to generate several "loops" to get the title, excerpt, thumbnail and permalink of a custom post type 'charity' by post ID, because I need to target each ID with a special class (absolute-positioned map pointers).
Can you help me adjust my code so I can get it to work? What I have so far doesn't work:
<span id="chty_17">
						<?php // Charity ThirtySix  
                        $args = array('post_type'=> 'charity','post__in' => array(36));
                        $custom_query = get_posts($args);
                        foreach ($custom_query as $post) :
                        setup_postdata($post); ?>
                        <dt><?php the_title; ?></dt>
                        <dd>
                        <?php echo get_the_post_thumbnail(); ?>
                        <h2><?php the_title; ?></h2>
                        <p><?php the_excerpt; ?></p>
                        <p><a class="more" href="<?php echo get_post_permalink();?>">Find out more &raquo;</a></p></dd>
                        <?php endforeach;
                        wp_reset_postdata();?>
                	</span>

Open in new window

This code only displays the thumbnail and permalink correctly. I tried other options like the below, but the excerpt isn't included:
<?php $post_17 = get_post(17); // ABORIGINAL CHRISTIAN VOICE NETWORK ?>
                        <dt><?php echo $post_17->post_title; ?></dt>
                        <dd>
                        <?php echo get_the_post_thumbnail('17'); ?>
                        <h2><?php echo $post_17->post_title; ?></h2>
                        <p><?php echo $post_17->post_content; ?></p>
                        <p><a class="more" href="<?php echo get_post_permalink('17');?>">Find out more &raquo;</a></p></dd>

Open in new window

Please help! Thanks!!
ASKER CERTIFIED SOLUTION
Avatar of cstela
cstela

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial