[英]How to set metadata when posting via email in Wordpress
I have a custom post defined that includes an item of metadata (a URL). 我定义了一个自定义帖子,其中包含一个元数据(URL)项。 My Wordpress loop displays the title of the post and links to the URL - the content is not displayed.
我的Wordpress循环显示帖子标题和URL链接-不显示内容。
Can anyone help me set up posting via e-mail in Wordpress such that the subject line is the title and the body is the URL? 谁能帮助我在Wordpress中设置通过电子邮件的发布,以便主题行为标题,正文为URL?
Thanks in advance. 提前致谢。
Wordpress provides a handy hook for posting via e-mail, publish_phone
. Wordpress提供了一个方便的钩子,用于通过电子邮件
publish_phone
。 Add this code into your functions.php in the active theme directory. 将此代码添加到活动主题目录中的functions.php中。
add_action('publish_phone', 'set_metadata');
function set_metadata($post_ID) {
$post = get_post($post_ID);
$content = $post->post_content;
$meta_key = 'url'; //the name of your metadata
update_post_meta($post_ID, $meta_key, $content);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.