我的解决方案是在二十个主题文件夹中工作,即文件“loop.php”
在145号线附近,我这样做了:
<?php $content = get_the_content( __( \'Continue reading <span class="meta-nav">→</span>\', \'twentyten\' ) );
// http://stackoverflow.com/a/6366390/1195835
// http://stackoverflow.com/a/11886237/1195835
// http://stackoverflow.com/a/15469353/1195835
$doc = new DOMDocument();
$doc->loadHTML($content);
$finder = new DomXPath($doc);
$classname = "post-main-image";
$nodes = $finder->query("//*[contains(concat(\' \', normalize-space(@class), \' \'), \' $classname \')]");
foreach($nodes as $node){
$node->setAttribute(\'href\',get_the_permalink());
}
echo $doc->saveHTML();
?>
然后在编辑帖子屏幕中,我只需在“Link CSS Class”表单字段中键入“post main image”并进行更新。我希望其他主题也能有类似的效果。