Saturday, December 31, 2022
HomeWordPress Developmentplugins - How do I save meta key worth within the save...

plugins – How do I save meta key worth within the save operate?


The edit code saves the heading worth in meta. How do I put it aside within the save operate?

The render_callback is as under. I attempted passing “render”: “file: path-to/php.php” in block.json however it would not work.

operate register_latest_post_item() {
    register_block_type("create-block/gadgets", [ "render_callback" => "render_latest_post_item"
    ]);
}
add_action("plugins_loaded", "register_latest_post_property_item");

operate render_latest_post_property_item( $worth, $object, $field_name ) {

Edit operate

import { __ } from '@wordpress/i18n';
import { useEntityProp } from "@wordpress/core-data";
import { useSelect } from "@wordpress/knowledge";
const {
    TextControl,

} = wp.elements;


import { useBlockProps } from '@wordpress/block-editor';

import './editor.scss';


export default operate Edit(props) {

const [meta, setMeta] = useEntityProp("postType", "itemizing", "meta");

const heading = meta["heading"];

const onChangeheading = (newValue) => {
    setMeta({ ...meta, heading: newValue });
    
};



return (
    <div {...useBlockProps()}>
        
        <div>
            <TextControl
                tagName="h1"
                label="title"
                className="card-title"
                worth={heading}
                onChange={onChangeheading}
            />
        </div>
    </div>
);
}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments