Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save mmarj/cfb81fd13657d2c13a0947f798d1179d to your computer and use it in GitHub Desktop.

Select an option

Save mmarj/cfb81fd13657d2c13a0947f798d1179d to your computer and use it in GitHub Desktop.

Revisions

  1. @amboutwe amboutwe revised this gist Apr 5, 2022. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion yoast_seo_opengraph_remove_subset.php
    Original file line number Diff line number Diff line change
    @@ -15,4 +15,5 @@
    add_filter( 'wpseo_og_og_image_width' , '__return_false' ); // v13.5 or older
    add_filter( 'wpseo_og_og_image_height' , '__return_false' ); // v13.5 or older
    add_filter( 'wpseo_opengraph_author_facebook' , '__return_false' );
    add_filter( 'Yoast\WP\Woocommerce\product_condition', '__return_false' );
    add_filter( 'Yoast\WP\Woocommerce\product_condition', '__return_false' );
    add_filter( 'Yoast\WP\Woocommerce\og_price', '__return_false' ); // True or False only
  2. @amboutwe amboutwe revised this gist Sep 2, 2020. 4 changed files with 44 additions and 1 deletion.
    16 changes: 16 additions & 0 deletions yoast_seo_opengraph_remove_all_post14.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    <?php
    /********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/

    /* Remove all OpenGraph tags
    * Credit: Alejandro https://github.com/jreviews
    * Last Tested: Sep 2 2020 using Yoast SEO 14.9 on WordPress 5.5.1
    */

    add_filter( 'wpseo_frontend_presenter_classes', 'wpseo_remove_opengraph' );

    function wpseo_remove_opengraph( $classes ) {
    $classes = array_filter($classes, function($class) {
    return strpos($class, 'Open_Graph') === false;
    });
    return $classes;
    }
    27 changes: 27 additions & 0 deletions yoast_seo_opengraph_remove_presenters.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    <?php
    /********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/

    /* Remove one of more Open Graph or Twitter tags
    * Credit: Rogério https://github.com/rgllm
    * Last Tested: Sep 2 2020 using Yoast SEO 14.9 on WordPress 5.5.1
    */

    add_filter( 'wpseo_frontend_presenter_classes', 'filter_presenters' );

    function filter_presenters( $filter ) {
    if (($key = array_search('Yoast\WP\SEO\Presenters\Twitter\Image_Presenter', $filter)) !== false) {
    unset($filter[$key]);
    }
    if (($key = array_search('Yoast\WP\SEO\Presenters\Open_Graph\Image_Presenter', $filter)) !== false) {
    unset($filter[$key]);
    }
    if (($key = array_search('Yoast\WP\SEO\Presenters\Twitter\Description_Presenter', $filter)) !== false) {
    unset($filter[$key]);
    }

    if (($key = array_search('Yoast\WP\SEO\Presenters\Open_Graph\Site_Name_Presenter', $filter)) !== false) {
    unset($filter[$key]);
    }

    return $filter;
    }
    2 changes: 1 addition & 1 deletion yoast_seo_opengraph_remove_subset.php
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@
    add_filter( 'wpseo_opengraph_title', '__return_false' );
    add_filter( 'wpseo_opengraph_type', '__return_false' );
    add_filter( 'wpseo_opengraph_site_name', '__return_false' );
    add_filter( 'wpseo_opengraph_image' , '__return_false' );
    add_filter( 'wpseo_opengraph_image' , '__return_false' ); // v13.5 or older
    add_filter( 'wpseo_og_og_image_width' , '__return_false' ); // v13.5 or older
    add_filter( 'wpseo_og_og_image_height' , '__return_false' ); // v13.5 or older
    add_filter( 'wpseo_opengraph_author_facebook' , '__return_false' );
  3. @amboutwe amboutwe revised this gist May 21, 2020. 1 changed file with 5 additions and 3 deletions.
    8 changes: 5 additions & 3 deletions yoast_seo_opengraph_change_image_size.php
    Original file line number Diff line number Diff line change
    @@ -3,10 +3,12 @@

    /* Change size for Yoast SEO OpenGraph image for all content
    * Credit: Yoast Development team
    * Last Tested: May 24 2019 using Yoast SEO 11.2.1 on WordPress 5.2.1
    * Last Tested: May 19 2020 using Yoast SEO 14.1 on WordPress 5.4.1
    * Accepts WordPress reserved image size names: 'thumb', 'thumbnail', 'medium', 'large', 'post-thumbnail'
    * Accepts custom image size names: https://developer.wordpress.org/reference/functions/add_image_size/
    */

    add_filter( 'wpseo_opengraph_image_size', 'yoast_seo_opengraph_change_image_size' );
    function yoast_seo_opengraph_change_image_size( $string ) {
    return 'medium_large';
    function yoast_seo_opengraph_change_image_size() {
    return 'medium';
    }
  4. @amboutwe amboutwe revised this gist May 20, 2020. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions yoast_seo_opengraph_remove_subset.php
    Original file line number Diff line number Diff line change
    @@ -12,5 +12,7 @@
    add_filter( 'wpseo_opengraph_type', '__return_false' );
    add_filter( 'wpseo_opengraph_site_name', '__return_false' );
    add_filter( 'wpseo_opengraph_image' , '__return_false' );
    add_filter( 'wpseo_og_og_image_width' , '__return_false' ); // v13.5 or older
    add_filter( 'wpseo_og_og_image_height' , '__return_false' ); // v13.5 or older
    add_filter( 'wpseo_opengraph_author_facebook' , '__return_false' );
    add_filter( 'Yoast\WP\Woocommerce\product_condition', '__return_false' );
  5. @amboutwe amboutwe revised this gist Feb 21, 2020. 2 changed files with 35 additions and 7 deletions.
    27 changes: 27 additions & 0 deletions yoast_seo_opengraph_change_product_condition.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    <?php
    /********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/

    /* Change Product Condition
    * Credit: Yoast team
    * Last Tested: Feb 20, 2020 using Yoast SEO WooCommerce 12.6 on WordPress 5.3.2
    *********
    * DIFFERENT POST TYPES
    * Post: Change 123456 to the post ID
    * Page: Change is_single to is_page and 123456 to the page ID
    * Custom Post Type: Change is_single to is_singular and 123456 to the 'post_type_slug'
    Example: is_singular( 'cpt_slug' )
    *********
    * MULTIPLE ITEMS
    * Multiple of the same type can use an array.
    Example: is_single( array( 123456, 234567, 345678 ) )
    * Multiple of different types can repeat the if statement
    */

    add_filter( 'Yoast\WP\Woocommerce\product_condition', 'yoast_seo_opengraph_change_product_condition' );
    function yoast_seo_opengraph_change_product_condition( $condition ) {
    if ( is_single ( 34 ) ) {
    $condition = 'used';
    }
    /* Use a second if statement here when needed */
    return $condition; /* Do not remove this line */
    }
    15 changes: 8 additions & 7 deletions yoast_seo_opengraph_remove_subset.php
    Original file line number Diff line number Diff line change
    @@ -6,10 +6,11 @@
    * Last Tested: Jul 28 2017 using Yoast SEO 5.1 on WordPress 4.8
    */

    add_filter('wpseo_opengraph_url' , '__return_false' );
    add_filter('wpseo_opengraph_desc', '__return_false' );
    add_filter('wpseo_opengraph_title', '__return_false' );
    add_filter('wpseo_opengraph_type', '__return_false' );
    add_filter('wpseo_opengraph_site_name', '__return_false' );
    add_filter('wpseo_opengraph_image' , '__return_false' );
    add_filter('wpseo_opengraph_author_facebook' , '__return_false' );
    add_filter( 'wpseo_opengraph_url' , '__return_false' );
    add_filter( 'wpseo_opengraph_desc', '__return_false' );
    add_filter( 'wpseo_opengraph_title', '__return_false' );
    add_filter( 'wpseo_opengraph_type', '__return_false' );
    add_filter( 'wpseo_opengraph_site_name', '__return_false' );
    add_filter( 'wpseo_opengraph_image' , '__return_false' );
    add_filter( 'wpseo_opengraph_author_facebook' , '__return_false' );
    add_filter( 'Yoast\WP\Woocommerce\product_condition', '__return_false' );
  6. @amboutwe amboutwe revised this gist May 24, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion yoast_seo_opengraph_change_image_size.php
    Original file line number Diff line number Diff line change
    @@ -9,4 +9,4 @@
    add_filter( 'wpseo_opengraph_image_size', 'yoast_seo_opengraph_change_image_size' );
    function yoast_seo_opengraph_change_image_size( $string ) {
    return 'medium_large';
    };
    }
  7. @amboutwe amboutwe revised this gist May 24, 2019. 2 changed files with 13 additions and 1 deletion.
    12 changes: 12 additions & 0 deletions yoast_seo_opengraph_change_image_size.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    <?php
    /********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/

    /* Change size for Yoast SEO OpenGraph image for all content
    * Credit: Yoast Development team
    * Last Tested: May 24 2019 using Yoast SEO 11.2.1 on WordPress 5.2.1
    */

    add_filter( 'wpseo_opengraph_image_size', 'yoast_seo_opengraph_change_image_size' );
    function yoast_seo_opengraph_change_image_size( $string ) {
    return 'medium_large';
    };
    2 changes: 1 addition & 1 deletion yoast_seo_opengraph_change_image_url.php
    Original file line number Diff line number Diff line change
    @@ -8,6 +8,6 @@

    add_filter( 'wpseo_opengraph_image', 'change_opengraph_image_url' );

    function change_opengraph_image_url($url) {
    function change_opengraph_image_url( $url ) {
    return str_replace('current_domain.com', 'new_domain.com', $url);
    }
  8. @amboutwe amboutwe revised this gist Nov 20, 2018. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion yoast_seo_opengraph_remove_subset.php
    Original file line number Diff line number Diff line change
    @@ -11,4 +11,5 @@
    add_filter('wpseo_opengraph_title', '__return_false' );
    add_filter('wpseo_opengraph_type', '__return_false' );
    add_filter('wpseo_opengraph_site_name', '__return_false' );
    add_filter('wpseo_opengraph_image' , '__return_false' );
    add_filter('wpseo_opengraph_image' , '__return_false' );
    add_filter('wpseo_opengraph_author_facebook' , '__return_false' );
  9. @amboutwe amboutwe revised this gist Jul 4, 2018. 1 changed file with 13 additions and 0 deletions.
    13 changes: 13 additions & 0 deletions yoast_seo_opengraph_change_image_url.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    <?php
    /********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/

    /* Change Open Graph image URLs in Yoast SEO
    * Credit: Yoast Development team
    * Last Tested: Jul 04 2018 using Yoast SEO 7.7.3 on WordPress 4.9.6
    */

    add_filter( 'wpseo_opengraph_image', 'change_opengraph_image_url' );

    function change_opengraph_image_url($url) {
    return str_replace('current_domain.com', 'new_domain.com', $url);
    }
  10. @amboutwe amboutwe revised this gist May 2, 2018. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion yoast_seo_opengraph_remove_subset.php
    Original file line number Diff line number Diff line change
    @@ -10,4 +10,5 @@
    add_filter('wpseo_opengraph_desc', '__return_false' );
    add_filter('wpseo_opengraph_title', '__return_false' );
    add_filter('wpseo_opengraph_type', '__return_false' );
    add_filter('wpseo_opengraph_site_name', '__return_false' );
    add_filter('wpseo_opengraph_site_name', '__return_false' );
    add_filter('wpseo_opengraph_image' , '__return_false' );
  11. @amboutwe amboutwe revised this gist Aug 25, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion yoast_seo_opengraph_remove_single.php
    Original file line number Diff line number Diff line change
    @@ -13,7 +13,7 @@
    *********
    * MULTIPLE ITEMS
    * Multiple of the same type can use an array.
    Example: is_single( array( 123456, 234567, 345678 ) );
    Example: is_single( array( 123456, 234567, 345678 ) )
    * Multiple of different types can repeat the if statement
    */

  12. @amboutwe amboutwe revised this gist Aug 25, 2017. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions yoast_seo_opengraph_remove_single.php
    Original file line number Diff line number Diff line change
    @@ -4,10 +4,17 @@
    /* Remove Yoast SEO OpenGraph Output From One Post/Page
    * Credit: Unknown
    * Last Tested: Apr 01 2017 using Yoast SEO 4.5 on WordPress 4.7.3
    *********
    * DIFFERENT POST TYPES
    * Post: Change 123456 to the post ID
    * Page: Change is_single to is_page and 123456 to the page ID
    * Custom Post Type: Change is_single to is_singular and 123456 to the 'post_type_slug'
    Example: is_singular( 'cpt_slug' )
    *********
    * MULTIPLE ITEMS
    * Multiple of the same type can use an array.
    Example: is_single( array( 123456, 234567, 345678 ) );
    * Multiple of different types can repeat the if statement
    */

    add_action('wp_head', 'remove_one_wpseo_og', 1);
    @@ -16,4 +23,5 @@ function remove_one_wpseo_og() {
    if ( is_single ( 123456 ) ) {
    remove_action( 'wpseo_head', array( $GLOBALS['wpseo_og'], 'opengraph' ), 30 );
    }
    /* Use a second if statement here when needed */
    }
  13. @amboutwe amboutwe revised this gist Aug 12, 2017. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions yoast_seo_opengraph_remove_single.php
    Original file line number Diff line number Diff line change
    @@ -6,6 +6,8 @@
    * Last Tested: Apr 01 2017 using Yoast SEO 4.5 on WordPress 4.7.3
    * Post: Change 123456 to the post ID
    * Page: Change is_single to is_page and 123456 to the page ID
    * Custom Post Type: Change is_single to is_singular and 123456 to the 'post_type_slug'
    Example: is_singular( 'cpt_slug' )
    */

    add_action('wp_head', 'remove_one_wpseo_og', 1);
  14. @amboutwe amboutwe revised this gist Aug 12, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion yoast_seo_opengraph_remove_single.php
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@
    add_action('wp_head', 'remove_one_wpseo_og', 1);

    function remove_one_wpseo_og() {
    if ( is_single ( 123456 ) {
    if ( is_single ( 123456 ) ) {
    remove_action( 'wpseo_head', array( $GLOBALS['wpseo_og'], 'opengraph' ), 30 );
    }
    }
  15. @amboutwe amboutwe revised this gist Jul 29, 2017. 3 changed files with 13 additions and 9 deletions.
    13 changes: 13 additions & 0 deletions yoast_seo_opengraph_remove_subset.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    <?php
    /********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/

    /* Remove Individual Yoast SEO OpenGraph meta tags
    * Credit: Yoast Development team
    * Last Tested: Jul 28 2017 using Yoast SEO 5.1 on WordPress 4.8
    */

    add_filter('wpseo_opengraph_url' , '__return_false' );
    add_filter('wpseo_opengraph_desc', '__return_false' );
    add_filter('wpseo_opengraph_title', '__return_false' );
    add_filter('wpseo_opengraph_type', '__return_false' );
    add_filter('wpseo_opengraph_site_name', '__return_false' );
    9 changes: 0 additions & 9 deletions yoast_seo_opengraph_remove_url.php
    Original file line number Diff line number Diff line change
    @@ -1,9 +0,0 @@
    <?php
    /********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/

    /* Remove Yoast SEO OpenGraph URL
    * Credit: Unknown
    * Last Tested: Unknown
    */

    add_filter('wpseo_opengraph_url' , '__return_false' );
  16. @amboutwe amboutwe revised this gist Jul 11, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions yoast_seo_opengraph_change_type.php
    Original file line number Diff line number Diff line change
    @@ -2,8 +2,8 @@
    /********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/

    /* Change Yoast SEO OpenGraph type
    * Credit: Unknown
    * Last Tested: Unknown
    * Credit: Yoast Team
    * Last Tested: Jul 11 2017 using Yoast SEO 5.0.1 on WordPress 4.8
    */

    add_filter( 'wpseo_opengraph_type', 'yoast_change_opengraph_type', 10, 1 );
  17. @amboutwe amboutwe revised this gist Jul 11, 2017. 1 changed file with 9 additions and 2 deletions.
    11 changes: 9 additions & 2 deletions yoast_seo_opengraph_change_type.php
    Original file line number Diff line number Diff line change
    @@ -9,6 +9,13 @@
    add_filter( 'wpseo_opengraph_type', 'yoast_change_opengraph_type', 10, 1 );

    function yoast_change_opengraph_type( $type ) {
    // Make magic happen here
    return 'website';
    /* Make magic happen here
    * Example below changes the homepage to a book type
    */

    if ( is_home() ) {
    return 'book';
    } else {
    return $type;
    }
    }
  18. @amboutwe amboutwe revised this gist Jun 17, 2017. 6 changed files with 67 additions and 62 deletions.
    62 changes: 0 additions & 62 deletions yoast-seo-change-remove-opengraph.php
    Original file line number Diff line number Diff line change
    @@ -1,62 +0,0 @@
    <?php
    /********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/

    /* Enforce HTTP Open Graph URLs in Yoast SEO
    * Credit: stodorovic https://github.com/stodorovic
    * Last Tested: Feb 06 2017 using Yoast SEO 4.2.1 on WordPress 4.7.2
    */

    add_filter( 'wpseo_opengraph_url', 'my_opengraph_url' );

    function my_opengraph_url( $url ) {
    return str_replace( 'https://', 'http://', $url );
    }

    /* Remove All Yoast SEO OpenGraph Output
    * There is an on/off switch in the plugin Admin > SEO > Social > Facebook
    * Credit: Unknown
    * Last Tested: Apr 01 2017 using Yoast SEO 4.5 on WordPress 4.7.3
    */

    add_action('wp_head', 'remove_all_wpseo_og', 1);

    function remove_all_wpseo_og() {
    remove_action( 'wpseo_head', array( $GLOBALS['wpseo_og'], 'opengraph' ), 30 );
    }

    /*
    * Remove Yoast SEO OpenGraph Output From One Post/Page
    * Credit: Unknown
    * Last Tested: Apr 01 2017 using Yoast SEO 4.5 on WordPress 4.7.3
    * Post: Change 123456 to the post ID
    * Page: Change is_single to is_page and 123456 to the page ID
    */

    add_action('wp_head', 'remove_one_wpseo_og', 1);

    function remove_one_wpseo_og() {
    if ( is_single ( 123456 ) {
    remove_action( 'wpseo_head', array( $GLOBALS['wpseo_og'], 'opengraph' ), 30 );
    }
    }

    /*
    * Change Yoast SEO OpenGraph type
    * Credit: Unknown
    * Last Tested: Unknown
    */

    add_filter( 'wpseo_opengraph_type', 'yoast_change_opengraph_type', 10, 1 );

    function yoast_change_opengraph_type( $type ) {
    // Make magic happen here
    return 'website';
    }

    /*
    * Remove Yoast SEO OpenGraph URL
    * Credit: Unknown
    * Last Tested: Unknown
    */

    add_filter('wpseo_opengraph_url' , '__return_false' );
    13 changes: 13 additions & 0 deletions yoast_seo_opengraph_change_protocol.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    <?php
    /********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/

    /* Enforce HTTP Open Graph URLs in Yoast SEO
    * Credit: stodorovic https://github.com/stodorovic
    * Last Tested: Feb 06 2017 using Yoast SEO 4.2.1 on WordPress 4.7.2
    */

    add_filter( 'wpseo_opengraph_url', 'my_opengraph_url' );

    function my_opengraph_url( $url ) {
    return str_replace( 'https://', 'http://', $url );
    }
    14 changes: 14 additions & 0 deletions yoast_seo_opengraph_change_type.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    <?php
    /********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/

    /* Change Yoast SEO OpenGraph type
    * Credit: Unknown
    * Last Tested: Unknown
    */

    add_filter( 'wpseo_opengraph_type', 'yoast_change_opengraph_type', 10, 1 );

    function yoast_change_opengraph_type( $type ) {
    // Make magic happen here
    return 'website';
    }
    14 changes: 14 additions & 0 deletions yoast_seo_opengraph_remove.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    <?php
    /********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/

    /* Remove All Yoast SEO OpenGraph Output
    * There is an on/off switch in the plugin Admin > SEO > Social > Facebook
    * Credit: Unknown
    * Last Tested: Apr 01 2017 using Yoast SEO 4.5 on WordPress 4.7.3
    */

    add_action('wp_head', 'remove_all_wpseo_og', 1);

    function remove_all_wpseo_og() {
    remove_action( 'wpseo_head', array( $GLOBALS['wpseo_og'], 'opengraph' ), 30 );
    }
    17 changes: 17 additions & 0 deletions yoast_seo_opengraph_remove_single.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    <?php
    /********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/

    /* Remove Yoast SEO OpenGraph Output From One Post/Page
    * Credit: Unknown
    * Last Tested: Apr 01 2017 using Yoast SEO 4.5 on WordPress 4.7.3
    * Post: Change 123456 to the post ID
    * Page: Change is_single to is_page and 123456 to the page ID
    */

    add_action('wp_head', 'remove_one_wpseo_og', 1);

    function remove_one_wpseo_og() {
    if ( is_single ( 123456 ) {
    remove_action( 'wpseo_head', array( $GLOBALS['wpseo_og'], 'opengraph' ), 30 );
    }
    }
    9 changes: 9 additions & 0 deletions yoast_seo_opengraph_remove_url.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    <?php
    /********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/

    /* Remove Yoast SEO OpenGraph URL
    * Credit: Unknown
    * Last Tested: Unknown
    */

    add_filter('wpseo_opengraph_url' , '__return_false' );
  19. @amboutwe amboutwe revised this gist Jun 8, 2017. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions yoast-seo-change-remove-opengraph.php
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    <?php
    /********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/

    /* Enforce HTTP Open Graph URLs in Yoast SEO
    * Credit: stodorovic https://github.com/stodorovic
  20. @amboutwe amboutwe revised this gist Apr 2, 2017. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions yoast-seo-change-remove-opengraph.php
    Original file line number Diff line number Diff line change
    @@ -17,9 +17,9 @@ function my_opengraph_url( $url ) {
    * Last Tested: Apr 01 2017 using Yoast SEO 4.5 on WordPress 4.7.3
    */

    add_action('wp_head', 'remove_wpseo_og', 1);
    add_action('wp_head', 'remove_all_wpseo_og', 1);

    function remove_wpseo_og() {
    function remove_all_wpseo_og() {
    remove_action( 'wpseo_head', array( $GLOBALS['wpseo_og'], 'opengraph' ), 30 );
    }

    @@ -31,9 +31,9 @@ function remove_wpseo_og() {
    * Page: Change is_single to is_page and 123456 to the page ID
    */

    add_action('wp_head', 'remove_wpseo_og', 1);
    add_action('wp_head', 'remove_one_wpseo_og', 1);

    function remove_wpseo_og() {
    function remove_one_wpseo_og() {
    if ( is_single ( 123456 ) {
    remove_action( 'wpseo_head', array( $GLOBALS['wpseo_og'], 'opengraph' ), 30 );
    }
  21. @amboutwe amboutwe revised this gist Apr 2, 2017. 2 changed files with 61 additions and 12 deletions.
    61 changes: 61 additions & 0 deletions yoast-seo-change-remove-opengraph.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,61 @@
    <?php

    /* Enforce HTTP Open Graph URLs in Yoast SEO
    * Credit: stodorovic https://github.com/stodorovic
    * Last Tested: Feb 06 2017 using Yoast SEO 4.2.1 on WordPress 4.7.2
    */

    add_filter( 'wpseo_opengraph_url', 'my_opengraph_url' );

    function my_opengraph_url( $url ) {
    return str_replace( 'https://', 'http://', $url );
    }

    /* Remove All Yoast SEO OpenGraph Output
    * There is an on/off switch in the plugin Admin > SEO > Social > Facebook
    * Credit: Unknown
    * Last Tested: Apr 01 2017 using Yoast SEO 4.5 on WordPress 4.7.3
    */

    add_action('wp_head', 'remove_wpseo_og', 1);

    function remove_wpseo_og() {
    remove_action( 'wpseo_head', array( $GLOBALS['wpseo_og'], 'opengraph' ), 30 );
    }

    /*
    * Remove Yoast SEO OpenGraph Output From One Post/Page
    * Credit: Unknown
    * Last Tested: Apr 01 2017 using Yoast SEO 4.5 on WordPress 4.7.3
    * Post: Change 123456 to the post ID
    * Page: Change is_single to is_page and 123456 to the page ID
    */

    add_action('wp_head', 'remove_wpseo_og', 1);

    function remove_wpseo_og() {
    if ( is_single ( 123456 ) {
    remove_action( 'wpseo_head', array( $GLOBALS['wpseo_og'], 'opengraph' ), 30 );
    }
    }

    /*
    * Change Yoast SEO OpenGraph type
    * Credit: Unknown
    * Last Tested: Unknown
    */

    add_filter( 'wpseo_opengraph_type', 'yoast_change_opengraph_type', 10, 1 );

    function yoast_change_opengraph_type( $type ) {
    // Make magic happen here
    return 'website';
    }

    /*
    * Remove Yoast SEO OpenGraph URL
    * Credit: Unknown
    * Last Tested: Unknown
    */

    add_filter('wpseo_opengraph_url' , '__return_false' );
    12 changes: 0 additions & 12 deletions yoast-seo-og-url-enforce-http.php
    Original file line number Diff line number Diff line change
    @@ -1,12 +0,0 @@
    <?php

    /* Enforce HTTP Open Graph URLs in Yoast SEO
    * Credit: stodorovic https://github.com/stodorovic
    * Last Tested: Feb 06 2017 using Yoast SEO 4.2.1 on WordPress 4.7.2
    */

    add_filter( 'wpseo_opengraph_url', 'my_opengraph_url' );

    function my_opengraph_url( $url ) {
    return str_replace( 'https://', 'http://', $url );
    }
  22. @amboutwe amboutwe renamed this gist Mar 14, 2017. 1 changed file with 0 additions and 0 deletions.
  23. @amboutwe amboutwe revised this gist Feb 7, 2017. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions yoast-seo-enforce-http-og-url.php
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    <?php

    /* Enforce HTTP Open Graph URLs in Yoast SEO
    * Credit: stodorovic https://github.com/stodorovic
    * Last Tested: Feb 06 2017 using Yoast SEO 4.2.1 on WordPress 4.7.2
  24. @amboutwe amboutwe created this gist Feb 7, 2017.
    11 changes: 11 additions & 0 deletions yoast-seo-enforce-http-og-url.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    <?php
    /* Enforce HTTP Open Graph URLs in Yoast SEO
    * Credit: stodorovic https://github.com/stodorovic
    * Last Tested: Feb 06 2017 using Yoast SEO 4.2.1 on WordPress 4.7.2
    */

    add_filter( 'wpseo_opengraph_url', 'my_opengraph_url' );

    function my_opengraph_url( $url ) {
    return str_replace( 'https://', 'http://', $url );
    }