Timeline for get_post_meta giving errors while creating a metabox
Current License: CC BY-SA 4.0
6 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Oct 16, 2020 at 4:08 | comment | added | Sash_007 | ok i have used wp nonce along with esc_html let me know if its ok ..check here ... pastebin.com/d3Y4vS3x | |
Oct 11, 2020 at 10:35 | comment | added | Sally CJ |
You should also validate, sanitize and escape user data, e.g. use esc_attr() with the <input> 's value and esc_html() when displaying the value, e.g. echo esc_html( get_post_meta( ... ) ) .
|
|
Oct 11, 2020 at 6:13 | comment | added | Sally CJ |
Yes, that's fine. And check out the docs for add_action() here, but the 10 means the callback's priority - if there were 4 callbacks hooked to save_post , that priority determines the position of your own callback, e.g. is it the first or last one that executes. And the 2 is the number of args your callback accepts, but you need to check the hook docs (e.g. this for save_post ) to know all the args for that specific hook.
|
|
Oct 10, 2020 at 3:54 | vote | accept | Sash_007 | ||
Oct 10, 2020 at 3:54 | comment | added | Sash_007 | hello thanks for reply and code works but can you please explain what 10 and 2 means in this line add_action( 'save_post', 'diwp_save_custom_metabox', 10, 2 ); ..i have seen that im few tutorials but didnt understand what that means? and to output the meta field data on front end i am using this code echo get_post_meta( $post->ID, 'post_reading_time', true ); is it ok? | |
Oct 9, 2020 at 5:07 | history | answered | Sally CJ | CC BY-SA 4.0 |