我想在我的网站上发布新博客的那一刻发布一篇facebook帖子。请帮我把这件事做完。
当我发布博客时在Facebook上发布
2 个回复
SO网友:Sacha
正如Robert hue所说,您必须为此使用插件。这里有很多Plugin directory, 但是你也可以编写自己的插件(或者将代码添加到主题的functions.php
如果找不到合适的或需要更多功能。
你会想加入publish_post
行动
例如:
function publish_post_to_facebook($ID, $post)
{
// Use the $post object to get information on the post, such as
// the post_title
// You could use the $ID of the post to generate a permalink,
// i.e., get_permalink($ID)
// Here would go your code to connect to Facebook and share the
// the post. You would likely need to use a Facebook PHP SDK
}
add_action( \'publish_post\', \'publish_post_to_facebook\' );
记住,在WordPress中,几乎所有内容都是一种帖子(包括页面)。你可能想检查一下$post->post_type == \'post\'
(或者您的自定义帖子类型,如果您正在使用)。有一个例子publish_post
吊钩用于Action Reference 在法典中。
SO网友:AddWeb Solution Pvt Ltd
我想你的问题是将你的博客帖子数据与你的facebook帐户同步,对吗。。?
实际上,你可以同步你的WordPress和Facebook帐户,这样,每次你在WordPress网站上发布文章时,一个链接就会自动在Facebook上共享。
请遵循以下URL:https://wordpress.org/plugins/social/
这可以更好地帮助你。
祝你好运。。!
结束