Unserialize Custom Field & Save as Multiple Rows in WordPress Database

I have found the way to get the values as I want them to be in the database. Changing the loop part in the above code with code did the trick. $data = get_post_meta( get_the_ID(), ‘combined’, true ); foreach($data as $singleData => $value ){ $thisArray = $data[$singleData]; foreach ($thisArray as $key2 => $value){ add_post_meta( get_the_ID(), … Read more

How to use wp_send_json() and output the value with ajax?

You can follow below steps: HTMl Code: <button id=”clickMe” data-nonce=”<?php echo esc_attr( wp_create_nonce( ‘my-nonce’ ) ); ?>”>Click Me</button> PHP Code: here you need to use wp_ajax hook. class myFunctions{ public function __construct(){ add_action( ‘wp_ajax_clickme’, [$this, ‘ajax_callback’]); // for logged in user only add_action( ‘wp_ajax_nopriv_clickme’, [$this, ‘ajax_callback’]); // for non logged user only } public function … Read more

WordPress 6.0 class-wp-widget.php fatal errors in PHP 8.1.6

I suspect the cause is a custom widget that has been built incorrectly. Take a look at this example from the Codex: class My_Widget extends WP_Widget { /** * Sets up the widgets name etc */ public function __construct() { $widget_ops = array( ‘classname’ => ‘my_widget’, ‘description’ => ‘My Widget is awesome’, ); parent::__construct( ‘my_widget’, … Read more