几天前我发了一篇文章" 如何为每个用户分别制作一个假的WordPress帖子 "
我设法通过使用此资源制作假帖子.除非我尝试使用自定义字段选项执行相同操作,否则一切都很好.我正在使用的主题有一个单独的自定义字段,wp_postmeta
其中包含嵌入式视频<div>
.
这是我尝试用于设置自定义字段选项的代码.
function kpg_f_content() {
global $wp_query;
$post = new stdClass();
$post -> ID = 1;
$post -> post_category = array('uncategorized');
//Add some categories. an array()???
$post -> post_content = 'hey here we are a real post';
//The full text of the post.
$post -> post_excerpt = 'hey here we are a real post';
//For all your post excerpt needs.
$post -> post_status = 'publish';
//Set the status of the new …
Run Code Online (Sandbox Code Playgroud) 嗨,我有 2 个数组,例如
array(a) { [0]=> array(2) { ["count"]=> string(2) "22" ["hour"]=> string(1) "0" }
[1]=> array(2) { ["count"]=> string(2) "17" ["hour"]=> string(1) "1" }
[2]=> array(2) { ["count"]=> string(2) "22" ["hour"]=> string(1) "2" }
[3]=> array(2) { ["count"]=> string(2) "15" ["hour"]=> string(1) "3" }
[4]=> array(2) { ["count"]=> string(2) "15" ["hour"]=> string(1) "4" }
}
Run Code Online (Sandbox Code Playgroud)
我有第二个数组具有不同的(计数)值
array(b) { [0]=> array(2) { ["count"]=> string(2) "12" ["hour"]=> string(1) "0" }
[1]=> array(2) { ["count"]=> string(2) "36" ["hour"]=> string(1) "1" }
[2]=> …
Run Code Online (Sandbox Code Playgroud) 我想创建一个博客页面,根据他/她的Facebook喜欢,活动等为特定用户生成内容.例如,我喜欢Shakira和可口可乐在Facebook上.当进入博客并通过Facebook连接时,博客会获取该信息,并通过YouTube API搜索Shakira的YouTube视频,并在WordPress帖子中向我显示视频.在博客搜索与可口可乐有关的新闻并在帖子中显示有关它的新闻之后.
FB连接,YouTube搜索或Google搜索没有问题.我的问题是WordPress.由于可以有很多用户并且可以为每个用户生成大量内容,因此我无法保存MySQL表中的每个帖子.我想动态生成帖子.我不是在这里要求代码,我只是想听听好的解决方案和想法如何才能做到这一点.