Wordpress custom post type structure - wordpress

i am building a wordpress website for a client. i need to build 1 template type of page with a list of fields that the client can fill in to populate the page. so lets say i build a template page called Person Template. On it i have an empty picture placeholder on the left and an empty Name Field below that. On the right i have an empty "persons phone number" and "Persons email" field.
what i need to create somehow is a system that the client can enter these 4 items into wp-admin somewhere and save that as a new Person. Then they can repeat and save another Person until they have created say 100 Person pages.
How do I do this? I tried building a Custom Post Type called Person CPT. I have built a Page called Person Template. I have built some "Person CPT" posts and put them on a page but i dont know how to create the Entry Fields page for my client to use.

You're correct that you'll need to use a custom post type. To add the fields you have two options:
Add the fields using add_meta_box(). You'll then need to save this data as post meta. Then in your single-person.php template you would retrieve the meta using get_post_meta(). It's a tad cumbersome, as you need to write the markup for the meta box, hook it into an action to add it to the admin page, and verify the content before it's saved. Here's an article that walks you through it
Alternatively get yourself the Advanced Custom Fields plugin: it makes adding additional fields very quick and easy. I use it all the time.

Related

In JetEngine Forms, where are the submissions / entries stored?

In WordPress JetEngine Forms you can create forms. When a user submits it, where does the data go? In GravityForms, you can edit a form and see a list of all submissions so far. Does JetEngine honestly lack that? Can't find it in the docs; can't find them in the DB either.
As a workaround you can auto-create a post of the (JetEngine) custom post type (i.e.) "form submission".
First set up the custom post type. Make sure to exclude it from the search. You can set it to private too, but then it doesn't appear in the forms dropdown anymore where we're gonna need it. (You can make the CPT public first, then set up the action, and make the CPT private afterwards. The association in the action's dropdown still stands, albeit now the dropdown value is empty … Seems a bit buggy and dangerous to do it that way)
Create a Meta Field for each form field.
Then edit the form and, next to "Send mail" or whatever your primary submit action is, add another action which is to "Insert/Update Post". Choose the CPT and map the form fields to the meta fields.
It's a bit cumbersome because of this redundant field management … But it's doable.

Add specific employee to a page in wordpress

We have created many pages in Wordpress and want to add an employee (name, phone, email etc.) to every page as responsible contact person. Now we want to add every contact person once in the backend and choose the right person in the page.
We also use Advanced Custom Fields (ACF) and could add a Field for adding the data, but it could be difficult if the employee gets a new phone number for example.
Has anyone an idea how to solve it in wordpress?
My proposition is:
Add custom post type named "Employees" to your WordPress.
Add custom fields (based on ACF) for contact data and assign them to mentioned post type.
Add post object field to your pages and assign employees post type to this field.
And it's done! Now you can assign a specific employee to your page as a post object and display data from it, like this.

Add a new section to the wp-admin edit post page

One of my post types is called Events and on here I have typical things like a post title, body, event date, etc.
In the site's code (on a custom template), I am programmatically adding meta to events when a user signs up (custom array of values).
The problem is that an admin can't see this data.
I wanted to know how I could add a custom section or template so when an admin inside wp-admin goes to any given event, and edits this single post/event, they can see the metadata associated.
I want to just add a new field section somewhere, called "Registrations", and then I'd programmatically access the meta and format it how I want, put some HTML/CSS in there, etc.
If anyone could point me in the right direction I would appreciate it.
Thanks!

WooCommerce - Custom User Registration Fields

I was following this blog post https://www.themelocation.com/how-to-add-custom-fields-to-user-registration-form-in-woocommerce/ to learn about creating custom user fields in Woo (for registration).
The post above worked, and I was able to see new fields during registration, but I had two questions:
How can I get these fields to appear when I'm editing a user in wp-admin? I didn't notice them rendering on the edit user page.
Right now Woo (by default) lets you just register with an e-mail. I wanted to also use a first name and last name (my custom fields), but this is already a field on the users in WordPress, so I don't want to duplicate fields. Is there a way to somehow pull in/use/associate an existing field (such as name) during the Woo registration?
Thanks so much for any help/guidance you all can give me.
1 You can use this plugin for display your custom fields in the admin view.
2 In your template HTML file, find the form, and use the default id & name tag : "Firstname" / "Lastname" ...ext

magic fields 2 // way to emulate write panel?

So Magic Fields 2 doesn't have "write panels." and since MF2 is so sleek - I am thinking there is some other thing that takes it's place that I can't find.
problem is this: creating a simple page with some fields in it.
in MF1//
create some m-Fields
create a page
fill out the fields on the page
select the fields that i want as a write panel.
echo them out on the page
STRUCTURE: page>fields
in MF2//
create a page template
create a page
assign the template to the page
create a custom post type
create the fields for that post type
create a post
fill in all the fields
run a loop in the page for the post type (for 1 post)
echo out the m-Fields data
STRUCTURE: page>post>fields
so a client would have to select the post type "about" then go in there and get(the only post in there) "about" then adjust the fields... meanwhile the page "about" is never touched... seems really strange...
or --- you could put ALL of the magic-fields on "page" - which in my case would mean that there would be 100 plus fields on every page and 90 of them wouldn't have to do with that page and then couldn't be required --- which is all way too confusing for clients.
I feel like I'm just not checking a special box somewhere.
The answer is just NO.
I have since started using Advance Custom Fields plugin and you just set up your custom field sets and tell them what page or post type to appear on. I have more confidence that ACF will stay up to date then the other plug in options. Just wanted to throw that out there.

Resources