我正在寻找一种在我的另一个自行编程的网站上共享(自动方式)我的WordPress条目的方法。换句话说:我想在我的网站中嵌入一篇特定的WordPress文章(以角度编码)。
有什么办法吗?
我正在寻找一种在我的另一个自行编程的网站上共享(自动方式)我的WordPress条目的方法。换句话说:我想在我的网站中嵌入一篇特定的WordPress文章(以角度编码)。
有什么办法吗?
你会尝试Wordpress REST Api? 这是一种将Wordpress网站的内容添加到其他网站的简单方法。
编辑:
在马克·卡普伦的评论表之后,我编辑了我的答案,并添加了一个“如何使用Wordpress REST API”的小示例。
API的基本路径始终为“/wp-json/wp/v2/”,并返回一个json字符串。
url示例:
https://wptavern.com/wp-json/wp/v2/
要获取特定帖子的数据,可以使用slug或post id等。示例帖子:
https://wptavern.com/an-update-to-my-gutenberg-experience
使用slug调用REST API:https://wptavern.com/wp-json/wp/v2/posts?slug=an-update-to-my-gutenberg-experience
使用post id调用REST API:https://wptavern.com/wp-json/wp/v2/posts/79564
我创建了这个small 使用jquery而不是angularjs编写示例,因为我对这个js框架没有任何经验。Sry。
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>
<style>
body {
background: white;
font-family: Helvetica;
}
#post-title {
border: 1px solid green;
padding: 5px;
}
#post-content {
border: 1px solid blue;
padding: 5px;
}
#post-link {
border: 1px solid red;
padding: 5px;
}
</style>
<script>
$( document ).ready(function() {
$.ajax({
type: \'GET\',
url: "https://wptavern.com/wp-json/wp/v2/posts/79564",
dataType: \'json\',
success: function(json)
{
$(\'#post-title\').html(json.title.rendered);
$(\'#post-content\').html(json.content.rendered);
$(\'#post-link\').html(json.link);
}
});
});
</script>
</head>
<body>
<div>POST Title</div>
<div id="post-title"> </div>
<div>POST Content</div>
<div id="post-content"></div>
<div>POST Link</div>
<div id="post-link"></div>
</body>
请参阅正在运行的代码:https://jsfiddle.net/5zqc3mdL/11/
在iframe中嵌入youtube视频时,可以启用隐私增强模式,这样youtube在播放视频之前不会存储有关网页访问者的信息。我尝试通过oEmbed和URL嵌入视频http://www.youtube-nocookie.com/embed/xA3tfBTvH0c但它没有起作用。是否有机会使用oEmbed实现隐私友好的解决方案?编辑我找到的this proposal 并试图对其进行定制,但有一点并不是最优的。您不能使用定义的$content\\u width,因为此解决方案也需要声明高度。对这种方法有什么想