合并Tiles PHP(Wordpress主题:Planar-lite)
抱歉,如果这是一个新手问题,我将非常感谢任何帮助。我正在自定义一个wordpress主题,我觉得必须合并PHP函数才能得到我想要的结果 主题是响应性的,并将帖子分为几块。但是,这些平铺被分解为图像,然后发布内容。我在想,我需要合并瓷砖,使缩略图图像是后瓷砖的背景。这可能吗 图像平铺功能合并Tiles PHP(Wordpress主题:Planar-lite),php,wordpress,themes,Php,Wordpress,Themes,抱歉,如果这是一个新手问题,我将非常感谢任何帮助。我正在自定义一个wordpress主题,我觉得必须合并PHP函数才能得到我想要的结果 主题是响应性的,并将帖子分为几块。但是,这些平铺被分解为图像,然后发布内容。我在想,我需要合并瓷砖,使缩略图图像是后瓷砖的背景。这可能吗 图像平铺功能 <figure class="tile" style="background: <?php echo esc_attr( get_theme_mod( 'planar_additional_color
<figure class="tile" style="background: <?php echo esc_attr( get_theme_mod( 'planar_additional_color', '#398ece' ) ); ?><?php $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id(), 'planar-quadratum' ); if( !empty($thumbnail) ) { ?> url(<?php echo $thumbnail[0]; ?>) no-repeat; background-size: cover; background-position:50%<?php } ?>;">
<img src="<?php echo get_template_directory_uri(); ?>/img/blank.png" alt="" width="800" height="800" />
</figure>
<article id="post-<?php the_ID(); ?>" <?php post_class('tile post'); ?>>
<img src="<?php echo get_template_directory_uri(); ?>/img/blank.png" alt="" width="800" height="800" />
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" class="tile-content<?php if ( !has_post_thumbnail()) : ?> no-thumbnail<?php endif; ?>" rel="bookmark">
<div class="entry-meta">
<?php
$category = get_the_category();
echo '<h3>' . $category[0]->cat_name . '</h3>';
if ( has_post_format() ) :
echo get_post_format_string( get_post_format() );
endif;
?>
<span><time datetime="<?php the_time('Y-m-d'); ?>"><?php the_date('j F Y', '<br />', '<br />'); ?></time></span>
</div><!-- .entry-meta -->
<h1 class="entry-title"><?php the_title(); ?></h1>
</a><!-- .tile-content -->
</article>
将style=“background image:url(”
添加到您希望背景图像所在的元素中
假设物品标签:
//to get the URL
<?php $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id(), 'planar-quadratum' ); ?>
//display
<article id="post-<?php the_ID(); ?>" <?php post_class('tile post'); ?> style="background-image:url('<?php echo $thumbnail)">
//code...
</article
//获取URL
//展示
将style=“background image:url(”
添加到要在其上显示背景图像的元素
假设物品标签:
//to get the URL
<?php $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id(), 'planar-quadratum' ); ?>
//display
<article id="post-<?php the_ID(); ?>" <?php post_class('tile post'); ?> style="background-image:url('<?php echo $thumbnail)">
//code...
</article
//获取URL
//展示
当然可以,如果答案确实解决了问题,你介意将其标记为已接受吗?谢谢你发布代码片段。它放置了一个空白图像,这很好,但它不是该帖子的特色图像。我应该使用“get\u template\u directory\u uri”吗或者其他东西来显示特色图片?啊,我以为这是一个占位符URL,用于这个问题。请稍等,我会编辑我的答案。您缺少一个结束php标记谢谢您的帮助。主题需要很多其他属性,所以为了保持主题的功能,我需要使用:style=“背景:url()不重复;背景大小:封面;背景位置:50%;”>
并将其粘贴到您指示我放置背景图像的位置。区别在于使用“背景:”标记而不是“背景图像:“当然,如果答案确实解决了问题,您介意将其标记为已接受吗?感谢您发布代码片段。它放置了一个空白图像,这很好,但它不是该帖子的特色图像。我应该使用“get\u template\u directory\u uri”吗?”或者其他东西来显示特色图片?啊,我以为这是一个占位符URL,用于这个问题。请稍等,我会编辑我的答案。您缺少一个结束php标记谢谢您的帮助。主题需要很多其他属性,所以为了保持主题的功能,我需要使用:style=“背景:url()不重复;背景大小:封面;背景位置:50%;”>
并将其粘贴到您指示我放置背景图像的位置。区别在于使用“背景:”标记而不是“背景图像:”