Working with custom post types on homepage

Hi all,

I’m using solely custom post types instead of normal posts. I have a few questions about this:

  • How can I use featured images for the slider, based on the custom post types? (images set by custom fields)
  • I’m able to print the excerpts of custom post types, but all the nice Dazzling markup is gone. How can I make the custom posts appear just as the normal posts on the home page?
  • The same questions go for the Popular/Recent widget, which only shows the normal posts.

I don’t need a full explanation but any help is welcome!

Edit: I was able to get the meta tags back by changing the post type in content.php:
<?php if ( ‘recensie’ == get_post_type() ) : ?>
‘recensie’ is the custom post type of my posts.

I’m still strugling with the images. On the custom post type page (content-single.php) the method I use to retrieve the image is this:
<img src="<?php the_field(‘header_afbeelding’); ?>" alt="" class=“thumbnail wp-post-image” />
Where ‘header_afbeelding’ is the custom field where the image is stored. However, the image is not used in the archive pages.

Hi @cyroq,

I hope you are well today and thank you for your question.

To display the image on archive page please overwrite the content.php file in your child theme by copying it from the Dazzling theme and adding it in the root directory of your child theme.

Then change the code in that copied content.php file on line number 44 as following Where ‘header_afbeelding’ is the custom field where the image is stored.

Before Editing :

<?php if ( has_post_thumbnail()) : ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
 	<?php the_post_thumbnail( 'dazzling-featured', array( 'class' => 'thumbnail col-sm-6' )); ?>
</a>

After Editing :

<?php if ( has_post_thumbnail()) : ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
 	<img src="<?php the_field('header_afbeelding'); ?>" alt="" class="thumbnail wp-post-image" />
</a>

Best Regards,
Movin