My-Meta-Box | A class for creating custom meta boxes for WordPress
kandi X-RAY | My-Meta-Box Summary
kandi X-RAY | My-Meta-Box Summary
My Wordpress Meta box Class.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of My-Meta-Box
My-Meta-Box Key Features
My-Meta-Box Examples and Code Snippets
Community Discussions
Trending Discussions on My-Meta-Box
QUESTION
I am relatively new to Post Meta Data in the WordPress backend using PHP. I have written the code that creates the Meta Data. I need help saving the data for which I have written. It will also need to allow me to edit the data once saved.
In this case its for a text field.
I have created the Meta Data for the input field which displays well in the back-end WordPress admin area.
...ANSWER
Answered 2019-Jun-24 at 22:06You were almost there.
The final part of the puzzle is the function that saves the metadata, but first we need to make a few adjustments to your existing code:
add_action( 'save_post', 'cd_meta_box_add', 10, 2 );
has to be moved outsidecd_meta_box_add()
, andChange
add_action( 'save_post', 'cd_meta_box_add', 10, 2 );
intoadd_action( 'save_post', 'cd_meta_box_add' );
as this action hook only receives one parameter (the post ID), andYou need to define the function that will process the data (and it can't be
cd_meta_box_add
as you have it now so we'll create a new one calledsave_cd_meta_box_data
).
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install My-Meta-Box
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page