0

Goal: To define content (phone number, address etc) in the admin area that can be used (called upon) in a theme.

Context: I am making a theme for a multi-site where every site will look the same, but have different content. The user should be able to easily add basic information in the admin area, preferably accessible through the left menu. The data fields will be predefined. It is important that each piece of data can be fetch independently.

My initial thoughts: Making a simple plugin where the user can enter the information. I was thinking of putting it in the functions.php file, but was not sure what would happen to the data if I made a new theme in the future.

Are there other obvious ways of accomplishing this that I haven't thought of? Any suggestions to how I could solve this in a future proof way?

Also, recommendations for good resources on the topic is appreciated!

3 Answers 3

1

Using functions.php inside your theme will have the functionality only for that theme.

I think a simple approach will be to create a plugin or a mu-plugin as @Benoti is suggesting where you will create a settings page that will be saved on options table.

There are a few guides to create admin pages: https://codex.wordpress.org/Creating_Options_Pages

There are also some ready made plugins like this ones: https://wordpress.org/plugins/search.php?q=options+page

From all available options I think is best to create your own options page as it is not very complicated and make it as a mu-plugin so all sites in your network will have it without the need of activation.

0
0

in your case I will make a plugin or a mu-plugin ( must-use plugin, which can not be desactivate) with a custom post type.

2
  • Why do you recommend a custom post type? My impression is that the data would then be organized much like the regular posts. I prefer that the data fields can be edited from one single page and not like the regular posts are edited, where you have to edit each page for itself. If that makes sense... Commented Nov 15, 2016 at 11:47
  • Cpt is just to separate blog pages from you users data, but of course you can do it with new user meta, new metaboxes in any post type (chose if you want it public pr not). And i will definitly avoid a third party plugin.
    – Benoti
    Commented Nov 15, 2016 at 20:02
0

I had a similar idea about 7 years ago and wrote a Django-inspired plugin called Chunks. It likely doesn't work anymore, but you can grab some ideas if you like:

https://wordpress.org/plugins/chunks/

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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