I just started diving into the wordpress world and i'm trying to add custom content to a website, i looked at the Customizer API and Meta box and they seem to be both able to add what i want which is custom content but i don't know which one of them is suitable for that. I'm trying to add list of services to a services page that i've created.
Neither of these really make sense
Why Not A Metabox/Post Meta?
What you're describing is not an attribute of a page, so it doesn't make sense as post meta shown in a metabox.
- You can't link directly to post meta
- Adding post meta to site search is difficult, and makes search 100x slower
- And if you did manage that, users wouldn't see the service they wanted, they'd just see the generic services page
- You'd have to write all the code to store and save it, then write it all over again to display it. Plugins can make it easier but it's still a pain in the arse
- Only your theme would be able to display the data
- Metaboxes are kind of legacy meh with the new block editor. It's all about custom blocks and sidebar panels now
Why Not A Control In The Customizer?
It also isn't a site wide control to customize how your site behaves and looks, so it doesn't go in the customizer! Besides:
- Those get stored as options and theme mods, so it doesn't scale as the list of services gets longer
- The newer iterations of the block editor are introducing the full site editing interface that replaces the customizer
- It's not easy to develop for
What you're describing is content.
So, you have 2 options that depend on just how in depth your services are.
If you're literally just listing them all on a page, why not just have a services page that lists them? You could use column blocks to do the classic image on the left, text on the right thing, cover blocks if you wanted a whole section, or even build your own block!
But, if you want to be able to link to a specific service, or have an entire page for a service, the next option would be better suited
A Service Custom Post Type
register_post_type to register a service post type. You'll get lots of free stuff ( they can be turned off when calling
- You'll get an archive to list services at
/services( configurable )
- Free templates (
- An entire new section of WP Admin in the sidebar dedicated to Services
- Free REST API endpoints ( set
show_in_restto true )
- RSS feeds!
- Dedicated URLs (
- Basic integration with SEO plugins
- Post meta! Now you can have featured images and all sorts of information about the services stored. So much more flexibility
- Child posts! What if your services had sub-services? Perhaps that gardening service has multiple specialities to hire
With a CPT, you could even register a custom taxonomy to organise them! Wouldn't it be nice to have a Service Type taxonomy? A County taxonomy for where the services are available? With their own URLs!
On top of all that, if you put the registration code in a plugin, the services post type will work with every theme!
Like you mentioned, you could potentially use either one.
In your situation, I would probably lean towards using a meta box. The Customizer is separated from your pages and posts, meaning you would have to go into Appearance > Customize to edit your list. While with a Meta Box, you can have that display directly on your page's edit screen.