The header image falls under what WordPress calls theme modification values. To update that type of value, use the function set_theme_mod()
function cs_set_logo($request) {
set_theme_mod('header_image', $request->get_param('new_header_image'));
return new WP_REST_Response(null, 200);
}
add_action('rest_api_init', function() {
register_rest_route('cs/v1', 'changelogo', [
'methods' => 'POST',
'callback' => 'cs_set_logo'
])
});
Related Posts:
- Changing custom logo link
- From where the header-text can be changed in WordPress custom header?
- WP HTTP API call response
- start_lvl Ignored in Custom walker_nav_menu
- Enforcing password complexity
- How do I make my function add variables/values to the $post object?
- Check if a menu is empty?
- Calculate percentage of post by category
- Dynamically change feature image in customiser
- Change comments form title on a page by page basis
- Creating wordpress user registration form
- Get the title before comma
- category not display in word press grammatically
- Getting a fatal error while updating
- “Can’t use function return value in write context” error
- Display 4 chronological posts starting with a random post
- my function doesn’t return my post from today
- Warning: array_pop() expects parameter 1 to be array, boolean given
- How to break down importing of feeds
- get_the_terms – only top level
- Have CSS Class Added with `is_page()` WP function
- Slide in Panel WordPress Post
- Use wp_get_recent_posts with search term
- Shortcode API: How to get name that matched shortcode RegEx?
- Run a filter when a walker runs
- comments_number display outside specified span
- Choose To Display Post Views With An Options Panel
- Prevent Data Resubmission On Page refresh
- Get_avatar filter?
- Display fields as values in array from external SQL DB
- Passing the custom field values in the wp_get_current_user array function
- Populate dropdown with Child Pages based on Parent Page chosen
- How can I remove a function that has been added to wordpress with add_filter?
- Create a range slider to change font-size with different screens sizes in wordpress customizer api
- Get value from shortcode to do something
- PHP 8, AJAX mail form to function.php doesn’t work
- Ajax request not sending to server and returning – wp-admin/admin-ajax.php 400
- What’s the uses of wp_cache_set() or wp_cache_add()?
- How to create a php variable using WordPress the_title() function
- Can’t find infinite loop cause
- how to make custom ajax handler?
- How to disable controls in theme customizer?
- is there a benefit in using a constant over get_stylesheet_directory_uri?
- WooCommerce Tabs [closed]
- Moving code from theme header to functions.php
- Best way to use a large array in function
- Setting user nickname and displayname to shortened email
- Download PDF after CF7 form submission
- ::before on open/close function [closed]
- REQUIRED: get_bloginfo(‘template_url’) was found in the file search.php. Use get_template_directory_uri() instead
- How to check if a PHP string is different than meta field?
- Displaying posts based on category
- Creating a mobile site by adding a new class to the body tag from functions.php
- Is it possible to create new user from external form using REST API?
- Export Form Data to a CSV then send it as an attachment – contact form 7
- Issue with fetching mysql data and displaying results via shortcode in webpage
- Noindex Posts From Certain Authors In WordPress
- How do I create a function that modifies a message in the wp-login.php file?
- Cant display an image via PHP in wordpress
- Template Loop – add switch case php
- Show all tags within a category?
- Image rotation issue (horizontal picture uploading as vertical) — Exif issue?
- Unable to Call More than One Meta Box Output
- How can I alter this code to accept a slug as well as an ID?
- Enqueueing a code block from an options framework
- Adding a ‘style=’ bit to image_send_to_editor output
- Auto create Nextgen Gallery on post creation [closed]
- Hide media for non logged in users
- Adding an “Upgrade Subscription” button to an Elementor page
- Generate images with html2canvas and the woocommerce api
- Dropdown category field inside repeatable metabox
- Retrieve alt text by referencing the img src
- Custom function that re-writes page title breaks when the Yoast plugin is activated
- is_front_page is not working in my functions.php
- Is it possible to update the dataset using update_post_meta
- update_user_meta as multiple value but with same meta key
- Hide payment method based on user role AND minimum cart value
- Delete post meta by serialized meta value
- Update $wpdb query with AJAX
- Create a temporal post
- How to bind each “the_content” elements to a custom variables
- Permalink changes after several minutes after saving post
- how to use auth_redirect() redirect visitor to login page if they are not login when they click account and order page?
- Trying to publish a little bit of Javascript on the homepage AND at the bottom
- Custom Bulk Actions handler not firing
- Get field in readable word
- How can disable wordpress emails notifications?
- How to fix blank pagination links?
- main menu page redirects to user ID
- How to have Function of a plugin using global vars into a shortcode?
- Adding header function to theme
- How can I clear the theme mod settings?
- Cant get theme to change footer color through theme customizer
- 2 small questions: How to redirect to a created page & show that pages title in wp, bp
- ACF Date fileds to Age Convert [closed]
- How do I get Roboto Google Font to display normal font-style? [closed]
- Loop on a wordpress Page instead of content coming from the WP text editor
- WP Custom tables query
- Custom Navigation Bar JSON Syntax Error in JSON at Position 0
- transition_post_status hook, works – but not if the post is new