How to change og:type | WordPress.org

[ad_1]

hi @stzm

During post edit you choose post type: video – this is the reason why OG publish it as video.

But if you want to change it programmatically for this post (ID: 793121), you can use this one:

<?php
add_filter( 'og_og_type_value', function( $value ) {
    if ( is_single( '793121' ) ) {
        return 'article';
    }
    return $value;
});

Marcin

Thread Starter
stzm

(@stzm)

Thank you for the reply. I would like to do it for all posts of the website not only for this post.

Then, it will be easier, fore every posts:

<?php add_filter( 'og_og_type_value', function( $value ) {
    return is_single()? 'article':$value;
});

Thread Starter
stzm

(@stzm)

I can’t thank you enough! I just applied the code and it works perfectly.

Thank you for this great plugin!

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer