简体   繁体   English

设置Wordpress首页的样式-特定帖子的外观

[英]Styling Wordpress frontpage-appearance of specific posts

I'm helping a friend out with a portfolio-site in Wordpress, with a specific idea of what the frontpage should look like. 我正在用Wordpress的一个组合站点帮助一个朋友,对首页应该是什么样子有一个特定的想法。 This is a quick sketch of his logo, and the post thumbnails are supposed to follow those dimensions. 这是他徽标的快速草图 ,帖子缩略图应遵循这些尺寸。 Posts on the frontpage are thumbnails only, no text or anything. 主页上的帖子仅是缩略图,没有文字或其他任何内容。 As I see it, this would mean that the thumbnail for the 2nd and 3rd post on the page has a specific styling, while posts 1, 4, 5 and 6 have another. 如我所见,这意味着页面上第二和第三帖子的缩略图具有特定的样式,而帖子1、4、5和6则具有其他样式。

Unfortunately I'm not a PHP mastermind, so I've been able to separate posts, but only from the first post and onwards, not from the 2nd to 3th post as needed. 不幸的是,我不是PHP的策划者,所以我能够将帖子分开,但只能将其从第一篇及以后的帖子中分离出来,而无需根据需要将其从第二篇到第三篇分开。

How can this be done, if possible? 如果可能的话,该怎么办?

Create Child Specific CSS 创建特定于儿童的CSS

nth-of-type(2n+1){ your css dode}; nth-of-type(2n + 1){您的CSS dode};

nth-of-type(2n+2){ your css dode}; nth-of-type(2n + 2){您的css dode};

nth-of-type(2n+3){ your css dode}; nth-of-type(2n + 3){您的css dode};

In your wordpress loop you could add classes to your posts, for example 在您的wordpress循环中,您可以将类添加到帖子中,例如

<?php 
    $i = 1;
if ( have_posts() ) {
    while ( have_posts() ) {
        the_post();  ?>
                    <div class="post<?php echo $i;?>">
                    <?php the_post_thumbnail();  
                    $i++;
    } 
}
?>

and style them like 并像

 .post1 .wp-post-image, .post4 .wp-post-image, .post5 .wp-post-image, .post6 .wp-post-image {
   width: 100px;
   height: 100px;
 }

 .post2 .wp-post-image, .post3 .wp-post-image {
   width: 200px;
   height: 200px;
 }

Did not test this, but it should work. 没有测试这个,但是它应该工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM