Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Boris Kamp
Boris Kamp
16,660 Points

What's your opinion on this approach?

Hi people!

Im currently hurting my brains due to lack of experience on how to best approach my situation: Im creating a new theme for my scale modelling website (it’s a hobby) completely from scratch. On this website I want users to – in a user friendly way! – be able to post:

  • reviews
  • finished projects
  • news articles
  • product info

I created cpt’s and custom taxonomies for all. everything is linked with vehicle categories, vehicle families, vehicle name, manufacturers, countries, product categories etc (all custom taxonomies).

In the product cpt the user can fill out this info:

  • manufacturer (of the product, not of the vehicle it represents or is made for) (taxonomy, e.g. ‘Tamiya’)
  • kit name (text)
  • kit number (text)
  • scale (taxonomy, e.g. ’1/35′)
  • price (number)
  • country of origin (taxonomy, e.g. ‘United States’)
  • product category (taxonomy, e.g. ‘model kit’)
  • vehicle category (taxonomy, e.g. ‘air vehicles’)
  • vehicle family (taxonomy, e.g. ‘F16 fighter jet’)
  • vehicle (taxonomy, e.g. ‘F16-D fighter jet’)

Now in the ‘review’ and ‘finished projects’ cpt’s I want to add a relationship field where the user can pick the product (from product cpt posts) when writing a review or finished product. Off course the product is what the review or finished project is about.

Reviews can be about a model kit and have no ‘target product’ they’re made for but – for example – detail sets are made specifically for ‘target products’. Thus I need another relationship in the ‘review’ cpt where the user can pick the ‘target product’ (from product cpt posts).

  1. What do you think about this approach? I want to make sure it’s a smart approach before I continue development on my website. I dont know if it matters, but it’s supposed to be a pretty big website in the future with a lot of records.

  2. if – for example – a review is linked to a product, will the taxonomies assigned to the product post also be assigned to the review post or is there a way to do so? I need this to show related content

  3. My last question, and an important one (user friendliness): imagine a product is not there yet? the user should go back and add the ‘product’ first before he can continue with the review or finished project. Is there a way to make the user create a product on-the-fly without leaving the current edit screen and navigating to products->add new product in the backend?

I would really appreciate if anybody gave his/her opinion about these two questions so I can move on without doubting on my approach.

Thanks people!

4 Answers

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

Did you by chance look for a related post plugin or something already built that can map related posts in acf?

For your question about adding content without leaving the page, the short answer is yes, but you would probably have to write some JS to just hide or show the extra fields in a separate from that they would submit first and then have access to the second one. It may be possible to submit all the data in one form, but that would require some extra work.

As a UI note, make sure you given then an auto complete search field or something like that and not a huge drop drown listing every product. Also think about the fact that the longer your forms are, they more drop-off rate you may have.

Boris Kamp
Boris Kamp
16,660 Points

Hi Zac Gordon ! Thanks for your input! I really appreciate your view on this! I hope you can help me out with this a little more though.

I did not yet arrive at the stage where I will focus myself on the related posts, so no, I did not check plugins yet. I will when the time comes! thanks for the tip

The fields listed above are in a single form called 'product info' (form #1). On the review edit page - for example - I add this form as the first form and a more specific review form (separate form, form #2). This review form contains a relational field where the user can select the product!

I get your point on JS, I was thinking of something like that as well but was wondering how can you fill out form #1 on a review edit page (add new product), press submit somehow (for form #1, not the review itself) and a new product is created and instantly available in the relational product field in form #2. All without reloading or changing pages?

About your UI note, Thanks for that! I already have a auto complete field for the products and taxonomies, so thats great! I will take the length of the forms in consideration! good point!

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

Hi,

I would recommend first thinking through how you may be able to simplify the process. If that's not an option then you're doing to have to figure out pull certain information out of the field after it's submitted, create the new post, process the reveiw and then figure out how to redirect to the correct page after everything is submitted. Does that sound correct?

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

Hi,

I would recommend first thinking through how you may be able to simplify the process. If that's not an option then you're doing to have to figure out pull certain information out of the field after it's submitted, create the new post, process the reveiw and then figure out how to redirect to the correct page after everything is submitted. Does that sound correct?

Boris Kamp
Boris Kamp
16,660 Points

Hi Zac Gordon, I don't think the process can be simplified much. I'm thinking of this process when an user adds a review or finished project:

  1. The first thing the user sees is a searchable an filterable list of all the products in the database (each product is a 'product' post)
  2. The user either finds the product and can continue to fill out the rest, DONE! if the product is not in there the user will continue to step 3:

  3. the user must press the 'add new product' button and a new ACF field group will appear with ACF fields to add a new product.

  4. The user will fill out the fields and press the 'add product' button to submit the data to a new 'product' post

  5. When submit is pressed the list from step 1 (ACF relationship field) must be refreshed somehow (jQuery?) and the user will be able to select the new product. DONE!

Step 1-2 are working perfectly, but I have no idea how to submit the data from step 4 into a 'product' post while the user is on the 'review' or 'finished project' post edit screen...... this is where I'm stuck, can you help me with this? I don't think the rest is that difficult.

Thanks!