I want to include a horizontal section at the very top of my site, above the header, that shows the next six events. I’ve created a custom post type called “events”, and I’ve created about 150 events.
That’s all fine, but what I’m having trouble with is figuring out how to create this new section above the header to get these events to display. Would I need to edit each page’s PHP to add that? Or is there something more global.
You could take the code used for the custom post type and save it as a file (in this case I’ll call it top.php). Upload top.php to the root of your theme folder. Make sure you remove the call to the header and footer. It might look something like this:
Once the file has been uploaded to your server inside the theme’s root folder, you can then place it inside the header.php file like so:
I hope that helps. Let me know if you have any questions.