2012-03-05 59 views
0

我有一个我想使用的wordpress代码,但我试图给它一些样式。一些Wordpress PHP中的CSS样式?

<?php global $post; 
$current_post = $post; // remember the current post 

for($i = 1; $i <= 1; $i++): 
    $post = get_previous_post(); // this uses $post->ID 
    setup_postdata($post); 

    // do your stuff here  
    the_excerpt(); 

endfor; 
$post = $current_post; // restore ?> 

即它说://做你的东西在这里,我需要添加永久和CSS样式到the_excerpt。目前the_excerpt在我的博客上拉起缩略图。

这是我用来获取2个随机缩略图的代码,希望这会给你一个我想要的上述代码的想法。

<?php 
$args = array('numberposts' => 2, 'orderby' => 'rand'); 
$rand_posts = get_posts($args); 
foreach($rand_posts as $post) : ?> 
<div class="postgallery" id="post-<?php the_ID(); ?>"> 
<a class="title" href="<?php the_permalink() ?>" rel="bookmark"><?php the_excerpt(); ?> 
<?php 
$thetitle = $post->post_title; /* or you can use get_the_title() */ 
$getlength = strlen($thetitle); 
$thelength = 35; 
echo substr($thetitle, 0, $thelength); 
if ($getlength > $thelength) echo "..."; 
?> 
</a><?php if ($options['tags']) : ?><?php endif; ?> 
</div> 
<?php endforeach; ?> 
+0

您可能会在我们的wordpress网站上获得更好的回复。如果您希望迁移该问题,请举报(请勿转贴)。谢谢。 – Kev 2012-03-06 23:40:43

回答

0

裹the_excerpt()与ID或类和会给你你需要通过风格样式表中摘录的内容挂钩一组div标签。