我的wordpress 主题默认是获取特色图片为缩略图,如何修改为自定义字段添加缩略图,
真是我主题缩略图代码,请问怎么修改,求大神详细说一下谢谢了。if($featured_image){$doc=newDOMDocument();$doc->loadHTM...
真是我主题缩略图代码,请问怎么修改,求大神详细说一下谢谢了。
if($featured_image) {
$doc = new DOMDocument();
$doc->loadHTML($featured_image);
$imageTags = $doc->getElementsByTagName('img');
foreach($imageTags as $tag) {
$image_url = $tag->getAttribute('src');
}
}
?>
<link rel="image_src" href="<?php echo $image_url; ?>" />
<h1><?php the_title(); ?></h1>
<?php if($oswc_featuredimage_size=="full" && has_post_thumbnail()) { ?>
<div class="article-image">
<?php the_post_thumbnail('single', array( 'title' => '' )); ?>
</div>
<?php } elseif($oswc_featuredimage_size=="medium" && has_post_thumbnail()) { ?>
<div class="article-image">
<?php the_post_thumbnail('single-medium', array( 'title' => '' )); ?>
</div>
<?php } elseif($oswc_featuredimage_size=="small" && has_post_thumbnail()) { ?>
<div class="article-image">
<?php the_post_thumbnail('single-small', array( 'title' => '' )); ?>
</div>
<?php } ?>
<div class="the-content">
<?php the_content(); ?>
</div>
<?php endwhile;
endif; ?>
</div>
</div> 展开
if($featured_image) {
$doc = new DOMDocument();
$doc->loadHTML($featured_image);
$imageTags = $doc->getElementsByTagName('img');
foreach($imageTags as $tag) {
$image_url = $tag->getAttribute('src');
}
}
?>
<link rel="image_src" href="<?php echo $image_url; ?>" />
<h1><?php the_title(); ?></h1>
<?php if($oswc_featuredimage_size=="full" && has_post_thumbnail()) { ?>
<div class="article-image">
<?php the_post_thumbnail('single', array( 'title' => '' )); ?>
</div>
<?php } elseif($oswc_featuredimage_size=="medium" && has_post_thumbnail()) { ?>
<div class="article-image">
<?php the_post_thumbnail('single-medium', array( 'title' => '' )); ?>
</div>
<?php } elseif($oswc_featuredimage_size=="small" && has_post_thumbnail()) { ?>
<div class="article-image">
<?php the_post_thumbnail('single-small', array( 'title' => '' )); ?>
</div>
<?php } ?>
<div class="the-content">
<?php the_content(); ?>
</div>
<?php endwhile;
endif; ?>
</div>
</div> 展开
1个回答
博思aippt
2024-07-20 广告
2024-07-20 广告
博思AIPPT是基于ai制作PPT的智能在线工具,它提供了4种AI制作PPT的方式,包括AI生成大纲、AI直接生成PPT、文本生成PPT、AI提炼word文档生成PPT,一站式集成多种AI生成PPT的方式,可满足办公用户的不同需求和使用场景...
点击进入详情页
本回答由博思aippt提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询