2012-03-05 39 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標籤。