2

I used to have both PCsteps.gr and Lifesteps.gr on the same server with the same IP. Oembed would work by default, I could embed posts from one site to the other without any problems.

However, since moving lifesteps.gr on a different server, embeds won't work anymore. It is my understanding that to embed lifesteps posts to pcsteps, I need to add lifesteps as an oembed provider to pcsteps.

I have added the following code, that I have created here.

    // Register oEmbed providers
function custom_oembed_provider() {

    wp_oembed_add_provider( 'https://www.lifesteps.gr/*', 'https://www.lifesteps.gr/oembed/', false );

}
add_action( 'init', 'custom_oembed_provider' );

However, this doesn't work. I suspect that the https://www.lifesteps.gr/oembed/ base url that I am using is wrong. However, I couldn't find if there is a default type for base oembed url for self-hosted wordpress sites.

1 Answer 1

0

In order for oEmbeds to work when embedding another WordPress site, the single template must have discovery links enabled. WordPress uses these to retrieve the oEmbed endpoint where the content is retrieved. These endpoints are a part of the REST API, so make sure that's enabled and working as well.

wp-includes/embed.php v5.1.1

if ( is_singular() ) {
    $output .= '<link rel="alternate" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n";

    if ( class_exists( 'SimpleXMLElement' ) ) {
        $output .= '<link rel="alternate" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n";
    }
}

Here's an example of that output:

<link rel="alternate" type="application/json+oembed" href="https://yourdomain.com/wp-json/oembed/1.0/embed?url=https%3A%2F%2Fyourdomain.com%2F2019%2F04%2F12%2Fpost%2F">
<link rel="alternate" type="text/xml+oembed" href="https://yourdomain.com/wp-json/oembed/1.0/embed?url=https%3A%2F%2Fyourdomain.com%2F2019%2F04%2F12%2Fpost%2F&amp;format=xml">

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.