0

I have a WordPress custom post type product and I am now developing front end forms for creating, reading and editing these posts (I am using ACF).

I am trying to use only single-product.php for this purpose! Can someone help me on this regard?

I already achieved to view (host/product/theproduct) and edit a post (host/product/theproduct?action=edit) basically by adding ?action=edit on the links and showing specific acf_form() if the $_GET["action"] is edit but I also want to use this page for creating new posts!

I tried to add new_product on URL like host/product/new_product and check on backend for that (and then show the create new product form) but because there is no new_product post it is redirecting to 404 page :(

I have no idea how to achieve this for the moment so any help/suggestion would be very appreciated!

Thanks in advance

1
  • You'd probably need to create a separate page with the same form on it for new products. Commented Jun 27, 2018 at 7:01

1 Answer 1

1

The context isn't really right for creating a new post. You'll be on single-product.php if you're viewing an existing post, but not for a post that you've yet to create!

I can think of two approaches.

1 - put an "Add Product" link or button onto your existing form and configure it so that a new product is created and you are redirected to that product so that you can now fill in your existing edit form to complete the data entry. I guess this kind of mirrors what the WP Admin does.

2 - just have a page template (or custom template with a custom URL rewrite) with the New Product form on, replicating pretty much what you already have in your edit form.

Hard to give some helpful code with no code in your question but hopefully these pointers will help.

1
  • I now that this request its kind of weird but it will help me a lot (not making many files)
    – Pito Axiu
    Commented Jun 23, 2018 at 14:49

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.