【问题标题】:Change og:url in WordPress SSL site to point to http将 WordPress SSL 站点中的 og:url 更改为指向 http
【发布时间】:2016-12-24 13:40:54
【问题描述】:

我最近搬到了 SSL,但失去了所有的 FB 赞。我在这里看到了其他答案,即Lost all Likes while moving to HTTPS 但不知道如何应用。例如,在 Simple Facebook Plugin 我可以看到代码:

$fbmeta['og:url'] = esc_url($permalink);

如何更改它以获取 http 版本?

【问题讨论】:

  • 你的意思是你把 https 改成 http 它让喜欢 0
  • 是的,仅适用于 og:url。这样它就可以从以前的 http 版本中获得“旧”的喜欢。
  • Really Simple SSL 插件具有“强制更改混合内容”,这意味着它不断强制网站上的每个链接到 http...
  • 我可以看到选中的“自动替换混合内容”,但我看不出这与 og:url 有什么关系
  • 为什么不手动放置

标签: wordpress facebook ssl


【解决方案1】:

案例一:借助插件加载混合内容

Really Simple SSL 插件具有“强制更改混合内容”,这意味着它不断强制网站上的每个链接到 http……

一些有用的功能

  • 混合内容扫描,向您展示如果您还没有绿锁,您必须做什么

  • 启用 HTTP 严格传输安全的选项

  • 为您的站点配置 HSTS 预加载列表的选项

  • 后端混合内容修复器

  • 更详细的配置页面反馈。

https://wordpress.org/plugins/really-simple-ssl/

案例 2:手动将 Facebook Open Graph 元数据添加到您的 WordPress 主题中

//Adding the Open Graph in the Language Attributes
function add_opengraph_doctype( $output ) {
        return $output . ' xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml"';
    }
add_filter('language_attributes', 'add_opengraph_doctype');

//Lets add Open Graph Meta Info

function insert_fb_in_head() {
    global $post;
    if ( !is_singular()) //if it is not a post or a page
        return;
        echo '<meta property="fb:admins" content="YOUR USER ID"/>';
        echo '<meta property="og:title" content="' . get_the_title() . '"/>';
        echo '<meta property="og:type" content="article"/>';
        echo '<meta property="og:url" content="' . get_permalink() . '"/>';
        echo '<meta property="og:site_name" content="Your Site NAME Goes HERE"/>';
    if(!has_post_thumbnail( $post->ID )) { //the post does not have featured image, use a default image
        $default_image="http://example.com/image.jpg"; //replace this with a default image on your server or an image in your media library
        echo '<meta property="og:image" content="' . $default_image . '"/>';
    }
    else{
        $thumbnail_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'medium' );
        echo '<meta property="og:image" content="' . esc_attr( $thumbnail_src[0] ) . '"/>';
    }
    echo "
";
}
add_action( 'wp_head', 'insert_fb_in_head', 5 );

其他解决方案

首先您必须更改网址请查看 FB 指南

https://developers.facebook.com/docs/plugins/faqs#faq_1149655968420144

您需要指示 facebook 爬虫重新抓取您的 url 以使更改生效:

https://developers.facebook.com/tools/debug/sharing

【讨论】:

  • 我已经安装了 Simple SSL 插件。它不能解决我的问题。在第二个解决方案中,我看不到如何
  • echo '';获取 http URL。
  • 在保持整体 SSL 的同时获得 FB 喜欢的任何东西 :)
  • 第二种方法添加到你的主题functions.php文件中
猜你喜欢
  • 2018-01-06
  • 1970-01-01
  • 2011-06-23
  • 2021-05-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-08-13
  • 2018-02-10
相关资源
最近更新 更多