How to create callback function which returns all posts with specific data?

Found! This function returns the specified fields for each post. function get_all ( $params ){ $posts = get_posts( array( ‘offset’ => 0, ‘post_status’ => ‘publish’ ) ); if ( empty( $posts ) ) { return null; } $posts_data = array(); foreach( $posts as $post ) { $posts_data[] = (object) array( ‘id’ => $post->ID, ‘date’ => … Read more

Warning and fatal error

Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘sanitize_comment_cookies’ not found or invalid function name in /homepages/9/d346623364/htdocs/wp-includes/class-wp-hook.php on line 286 This means you have a function named sanitize_comment_cookies hooked to an action or filter, either in your theme or a plugin, but that function is not available. Look for the code: add_action(‘some_action_name’, … Read more

Call function with button and return response

Based on the limited detail of your question something as per the following is a rough gist of what you could do. In your theme functions.php file: <?php function handle_request () { if (isset($_GET[‘custom_id’]) && isset($_GET[‘custom_id_nonce’]) ) { if ( wp_verify_nonce($_GET[‘custom_id_nonce’], ‘custom_id_action’) ) { $id = $_GET[‘custom_id’]; // FIRST // do something with $id // … Read more

How to ‘clone’ select metabox options with a callback function? [closed]

Add a simple function in your functions.php file. function get_button_styles(){ return array( ‘button’ => ‘Button’, ‘button_red’ => ‘Button Red’, ‘button_yellow’ => ‘Button Yellow’, ); } Use it to get button styles in different metabox fields array( ‘id’ => ‘all_btns’, ‘name’ => ‘Button Select’, ‘type’ => ‘select’, ‘options’ => get_button_styles(), ‘callback’ => ‘metabox_clone_options’, ),