Timeline for How do I display a custom field in an existing form on the front end?
Current License: CC BY-SA 4.0
33 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
May 2, 2018 at 14:42 | comment | added | abc0213 | Let us continue this discussion in chat. | |
May 2, 2018 at 14:01 | comment | added | Sally CJ |
So, if in the form (i.e. the page source or HTML) you see <input type="hidden" name="my_dates_post_ID" value="123" /> , then the $_POST['my_dates_post_ID'] would be 123 after you submit the form. Try this - add echo $_POST['my_dates_post_ID']; before this: $my_dates_MB->save_post( $_POST['my_dates_post_ID'] ); - and see if the values match.
|
|
May 2, 2018 at 13:55 | comment | added | Sally CJ |
The hidden input stores the ID of the post where the custom field was attached to. It is also an indicator that the custom field was changed via manual input on the front-end, and that it was for the post with the specified ID (in the hidden input ). Which means, if the input was submitted, then we can save the changes.
|
|
May 2, 2018 at 13:46 | comment | added | abc0213 | Do I need to do anything to the backend template and display page template to get them to speak to the form? | |
May 2, 2018 at 13:40 | comment | added | abc0213 | It still seems to not be working, could you explain a bit about what the hidden input does? The form doesn't save the data I've added in the back end into any fields, and the display page only shows the data I've added on the backend. | |
May 2, 2018 at 8:46 | comment | added | Sally CJ | Try the updated code. (Marked "UPDATED") | |
May 2, 2018 at 8:42 | history | edited | Sally CJ | CC BY-SA 4.0 |
added 194 characters in body; added 4 characters in body
|
May 1, 2018 at 21:38 | comment | added | abc0213 | The field displays properly now with your code, it was an issue with my script. The only thing that doesn't work now is the saving part. It doesn't seem to be saving to the admin metabox or displaying on the front end page that shows the metabox data. | |
May 1, 2018 at 21:28 | vote | accept | abc0213 | ||
Apr 26, 2018 at 12:53 | comment | added | Sally CJ | Well then, I'm giving up.. sorry about that, but I'm not able to test the listingpro-plugin for the time being. I've also rolled back the answer to the previous version (2 days ago). Hopefully the answer would help others. =) | |
Apr 26, 2018 at 12:49 | history | rollback | Sally CJ |
Rollback to Revision 4
|
|
Apr 26, 2018 at 12:45 | history | rollback | Sally CJ |
Rollback to Revision 5
|
|
Apr 25, 2018 at 15:36 | comment | added | abc0213 | this one didn't work either | |
Apr 25, 2018 at 14:19 | history | edited | Sally CJ | CC BY-SA 3.0 |
added 55 characters in body
|
Apr 25, 2018 at 14:13 | comment | added | Sally CJ |
I've updated the answer. Please remove the code you added in the template (the one before the get_header() line), and try the one I added to the answer.
|
|
Apr 25, 2018 at 14:12 | history | edited | Sally CJ | CC BY-SA 3.0 |
added 73 characters in body
|
Apr 25, 2018 at 13:59 | comment | added | Sally CJ | Ok, I still have some options. Or one option that should really work. I'll update the answer soon. | |
Apr 25, 2018 at 13:56 | comment | added | abc0213 | Unfortunately, this didn't work either... | |
Apr 23, 2018 at 23:16 | history | edited | Sally CJ | CC BY-SA 3.0 |
Updated screenshot.
|
Apr 23, 2018 at 22:32 | comment | added | Sally CJ |
Sorry about the $my_dates_MB . I actually made it a global variable, but I didn't include it as global in the answer. Would you mind trying again? In case the scripts would be magically loaded now?..
|
|
Apr 23, 2018 at 22:29 | history | edited | Sally CJ | CC BY-SA 3.0 |
added 277 characters in body
|
Apr 23, 2018 at 21:05 | comment | added | abc0213 | the scripts aren't loading either even though I placed the exact code above the get_header(); | |
Apr 23, 2018 at 20:26 | comment | added | abc0213 | $my_dates_mb->show(); is causing issues (blank white page) | |
Apr 23, 2018 at 19:00 | comment | added | Sally CJ | I didn't check the plugin; but please see the updated answer. | |
Apr 23, 2018 at 18:59 | history | edited | Sally CJ | CC BY-SA 3.0 |
added 26 characters in body
|
Apr 23, 2018 at 18:30 | comment | added | abc0213 | listingpro-plugin | |
Apr 23, 2018 at 18:15 | comment | added | Sally CJ | Could be. What plugin is that? Perhaps I can check it. | |
Apr 23, 2018 at 15:29 | comment | added | abc0213 | Yep, used the same code. This form is part of another plugin by the way, so I'm not sure if that's why the scripts and styles aren't loading? | |
Apr 19, 2018 at 1:39 | comment | added | Sally CJ | Did you add/use the exact code in my answer, or did you alter it in any way? The Meta Box stylesheet and script files may not be loaded on the page. | |
Apr 18, 2018 at 14:09 | comment | added | abc0213 | Just checked, there's no errors about the datepicker or library. | |
Apr 18, 2018 at 13:49 | comment | added | Sally CJ | Sounds to me like a jQuery/JS/scripts conflict(s). Did you try to view the browser console, to see if there are errors related to the date picker script or library? | |
Apr 18, 2018 at 13:36 | comment | added | abc0213 | It still seems to not be working for me. It displays it on the page now, but the input field isn't using the date picker and when I click +add more, it doesn't do anything. Not sure if this could be why, but it won't place itself within the div even though I've placed the code within a div. | |
Apr 18, 2018 at 5:30 | history | answered | Sally CJ | CC BY-SA 3.0 |