I have a function to get Custom posts title and picture. When I place it in header.php
it works as it should be. For some reason when I put the shortcode into the Wordpress home page, it shows "HomePage" without a picture.
How can I display custom post title and image in home page?
function show_credit_cards_posts() {
$custom_query = get_posts( array(
'post_type' => 'credit-cards',
'post_status' => 'publish',
'posts_per_page' => -1,
'caller_get_posts'=> 1
)
);
foreach ($custom_query as $post) :
setup_postdata($post); ?>
<div class="top-button">
<div class="img-holder"><?php echo get_the_post_thumbnail(); ?></div>
<?php the_title(); ?>
</div>
<!-- <p><a class="more" href="<?php // echo get_post_permalink();?>">Find out more »</a></p></dd> -->
<?php endforeach;
wp_reset_postdata();
}
add_shortcode( 'show-credit-cards-blocks', 'show_credit_cards_posts' );