Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3277788
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:24:30+00:00 2026-05-17T19:24:30+00:00

I’m in the process of creating a plugin which creates several custom post types

  • 0

I’m in the process of creating a plugin which creates several custom post types (CPT) (all of which work just fine). Some of these CPTs require a ‘custom write panel’ which basically means that it has a set of custom meta boxes rather than the bog-standard ‘edit’ box you get with your posts or pages.

One of these CPTs requires a ‘dynamic’ set of meta boxes which basically has an indeterminate amount of values. I’ll try and give an example:

(this isn’t what I’m doing, but it seems like a decent example of how I’d like it to work)

Imagine we have a CPT of ‘houses’ and one of the custom meta options for this CPT is ‘bedrooms’ – obviously, different houses have different amount of bedrooms, all of which have different properties. So, I’d like to be able to allow the user to add several different properties about a bedroom i.e.

Dimensions, aspect, number of windows and floor type

When the user has added these details for the first bedroom, if the house has a second bedroom then I would like them to have an ‘add bedroom’ button and another set of these meta boxes is added so they can fill out the details about bedroom 2.

I understand that I’ll need some javascript to add this facility (and something I don’t mind writing) but what I’m struggling with in my poor, useless brain is how to save these to the database. I want to achieve this using WordPress meta so that I don’t add any unnecessary database tables and I’m sure it’s possible I just can’t quite fathom the principles of how to save the data.

Pointers to any tutorials would be brilliant, or some examples of plugins which already do this kind of thing would be very gratefully received.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T19:24:30+00:00Added an answer on May 17, 2026 at 7:24 pm

    I think the best way to do this would be to use arrays within the forms. If you just had a collection of values which were saved to post_meta, you would only be able to link them back to the post (in this case house) but not which dimensions match which floor type etc

    If you had the names of each form field something like
    bedroom[width], bedroom[num_windows], bedroom[bed_type] etc, you would store an array within the post_meta table, so when you get the post meta for the bedroom of a house, it would return an array of arrays (the first level represnting the rooms, the second representing the attributes of a room

    You could even take it a step further if you wanted, and name the field bedrooms[i][attribute] where i is a counter you maintain within the JS. Then you would only have a single piece of post meta for all the bedrooms

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a text area in my form which accepts all possible characters from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to select an H1 element which is the second-child in its group
I have thousands of HTML files to process using Groovy/Java and I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.