【发布时间】:2011-08-03 22:33:42
【问题描述】:
我知道这个问题属于 wordpress 论坛,但我已经在那里发布了大约六个问题并且从未得到任何回复 - 我更喜欢这里的社区,请不要将此问题移至 wordpress。
我正在寻找一种方法来提取某个类别的最新帖子的附件(可以是照片、youtube vid 或 soundcloud 歌曲),调整其大小,然后将其显示在我的主页上。查看我的网站http://beachief.com/ 了解我的意思——“每日酋长”和“部落音乐”部分是我想要执行此操作的地方。我使用以下代码成功调整了这两个部分上方的图像大小:
<img src="<?php bloginfo('template_url'); ?>/images/philadelphia.jpg" alt="Featured picture" class="scaled"/>
但这仅适用于我有确切文件位置的图像。这是我用来获取最新帖子并显示其中一些内容的代码:
<ul class="link-item"> <?php $feature_post = get_posts( 'category=4&numberposts=1' ); ?>
<?php foreach( $feature_post as $post ) : setup_postdata( $post ); ?>
<li><h2 class="link-item"><?php the_category(' '); ?></h2></li>
<?php endforeach; ?>
<?php $feature_post = get_posts( 'category=4&numberposts=1' ); ?>
<?php foreach( $feature_post as $post ) : setup_postdata( $post ); ?>
<li class="list-time"><?php the_time('d'); ?>.<?php the_time('M'); ?></li>
<li class="list-title"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></li>
<li class="link-item"><?php the_excerpt(); ?></li>
<?php endforeach; ?> </ul>
我想去掉摘录并显示帖子附件,调整大小以匹配列宽。我怎样才能做到这一点?谢谢
【问题讨论】:
标签: php wordpress customization