1

我安装了插件http://wordpress.org/plugins/automatic-featured-image-posts/但我遇到了问题,因为插件在创建特色图像后不会从帖子内容中删除原始图像。(因此,当我不添加特色图片时,帖子上会出现 2 张图片)我尝试将其添加到 auto-featured-image.php

add_action('publish_post', 'eliminaroriginal');

接着

function eliminaroriginal(){ //更新没有图片的帖子 $post_parent_id = $post->post_parent === 0 ? $post->ID : $post->post_parent; $contenido = preg_replace("/[caption .+?[/caption]|\< [img][^>] [.]*>/i", "", $post->post_content, 1); $mipost = 数组();$mipost['ID'] = $post_parent_id; $mipost['post_content'] = $contenido; wp_update_post($mipost); }

但它没有任何结果。请帮帮我,我不知道我该怎么办。

先谢谢你了!

4

0 回答 0