Home Forums Event Espresso Premium Set a featured image using the REST API

Set a featured image using the REST API

Posted: June 11, 2020 at 3:29 pm


June 11, 2020 at 3:29 pm


I am unable to figure out how to use the REST API to add featured_media to an espresso_events post type.

I tried the wp endpoint using espresso_events as the custom post type (this is how it should work if espresso_events is a CPT):

JSON payload:
    "featured_media": "2620"

I get this:

    "message": "No route was found matching the URL and request method",
    "code": "rest_no_route",
    "data": {
        "status": 404

I also tried sending the featured_media param to the ee events REST API but that didn’t work – unsupported.

    "message": "You have provided an invalid parameter: "featured_media"",

Is it possible to set a featured image on an event_espresso event using the REST API? If so, would you provide a pointer to code or a sample CURL call I can adapt?



June 11, 2020 at 3:42 pm

Hmmm… I found this code shortly after posting this request. It allowed the first REST API request to work. I am now able to add a featured image using the featured_media json payload.

However, I wonder if this is the correct way:

 * Add REST API support to an already registered post type.
function tasny_post_type_args( $args, $post_type ) {
    if ( 'espresso_events' === $post_type ) {
        $args['show_in_rest'] = true;
    return $args;
add_filter( 'register_post_type_args', 'tasny_post_type_args', 10, 2 );


  • Support Staff

June 12, 2020 at 4:23 am

Hi Daniel,

There’s nothing wrong with using that method, it sets EE posts types to be available on the standard WP endpoints and as EE events are a custom post type you can use the usual parameters.

You must be logged in to reply to this support post. Sign In or Register for an Account

Support forum for Event Espresso 3 and Event Espresso 4.
Documentation for EE3 and EE4
Documentation for Event Espresso 3 Documentation for Event Espresso 4

Status: publish

Updated by  Tony 4 months, 2 weeks ago ago

Topic Tags


This topic is: not resolved
Do NOT follow this link or you will be banned from the site!