每次上载新图像时afip_new_post_content
调用过滤器,可用于在创建之前更改帖子内容-http://wordpress.org/extend/plugins/automatic-featured-image-posts/
假设您有一个url列表存储在某个地方,比如数据库中,那么您需要一个从该列表中获取url的函数,然后从该列表中删除您使用的url,这样它就不会再次被使用。
function get_one_url(){
/**
* your urls would be stored somewhere I suppose. Everytime you get a url,
* the number of URLs would decrease by one.
*/
//this is just a sample. you could probably build this using a database call.
$list_of_urls = array(
"http://url1.com",
"http://url2",
"http://url3"
);
//get the first url off the list and save it to the variable $url
$url = array_shift( $list_of_urls );
//save new list to database. This is just a sample.
save_my_list( $list_of_urls );
return $url;
}
add_filter( \'afip_new_post_content\', \'diww_default_post_content\' );
function diww_default_post_content() {
$url = get_one_url();
$content = "<iframe src={$url}></iframe>";
return $content;
}
?>