0

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.

  • If you want to just add a list why not use the List Block? gogutenberg.com/blocks/list – RiddleMeThis Mar 4 at 20:46
  • @RiddleMeThis im not trying to add a list as in a normal list there custom blocks thats show each services with a title and description and icon – Black Iso Mar 4 at 20:54
0

Neither!

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.

Additionally:

  • 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.

Page Content

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

Use register_post_type to register a service post type. You'll get lots of free stuff ( they can be turned off when calling register_post_type too:

  • You'll get an archive to list services at /services ( configurable )
  • Free templates ( single-service.php and archive-service.php anybody? )
  • An entire new section of WP Admin in the sidebar dedicated to Services
  • Free REST API endpoints ( set show_in_rest to true )
  • RSS feeds!
  • Dedicated URLs ( yoursite.com/services/gardening? )
  • 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! yoursite.com/services/county/derbyshire?

On top of all that, if you put the registration code in a plugin, the services post type will work with every theme!

| improve this answer | |
  • They don't link to anything there just small boxes that shows on the services page (page-services.php) and the home page. – Black Iso Mar 4 at 21:13
  • i didn't understand what did you meant by there not an attribute of a page ? – Black Iso Mar 4 at 21:14
  • Well content is content, it belongs in the content. That's what gets indexed, searched, etc. Attributes are things about an item/thing, not the thing itself. So for example, the price of a product, the colour of a book, etc, information about the post that isn't the content/title itself. If these are just small boxes, then use content, be that blocks, shortcodes, images, etc – Tom J Nowell Mar 4 at 21:18
  • If i use custom blocks dose that mean you have to edit the services in every pages they show up on because i want them to show up on the home page as well as the services page ? – Black Iso Mar 4 at 21:26
  • this is what im trying to do – Black Iso Mar 4 at 21:30
0

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.

There are obviously more differences between the two but that would be the main one for me. You can read more about the Customizer here and Meta Boxes here.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.