Different meta if post is custom post type 'agenda'
-
I’m making my own template. To display events I made a custom event-list with the help of this tutorial: https://www.makeuseof.com/tag/events-listing-custom-post-types-wordpress/.
All works fine, however when I open an ‘event’ (which is basically a post) WordPress will still display the meta information of a normal single-post. This makes sense, but I would like to change WordPress, so that when the post type is ‘agenda’, it will replace the default meta information with my own meta information.
Default meta information
<span class="postmeta"><img class="date" src="https://tikvah.unitymedia.nl/wp-content/themes/Petachtikvah_v2/images/icons/date.png"> <?php the_time('l d F Y') ?>, <?php the_time('G:i') ?><img src="https://tikvah.unitymedia.nl/wp-content/themes/Petachtikvah_v2/images/icons/user.png"> <?php the_author(); ?><img src="https://tikvah.unitymedia.nl/wp-content/themes/Petachtikvah_v2/images/icons/category.png"> <?php the_category(', ') ?></span>
Meta information to be showed if post type ‘agenda’
<ul class="eventdetails"> <li><b>Locatie:</b> <?php $locatie = get_post_meta($post->ID, 'locatie', true); if ($locatie){ echo $locatie; } ?> </li> <li><b>Tijdstip:</b> <?php $tijd = get_post_meta($post->ID, 'tijd', true); if ($tijd){ echo $tijd; } ?></li> </ul>
Obviously this is just an example…but I hope you can help me out here. I have tried using custom post ifs…..but so far I would not give me what I’m looking for.
- The topic ‘Different meta if post is custom post type 'agenda'’ is closed to new replies.