2011-05-23 38 views
1

我需要制作一个WordPress的博客显示的主页,只有1个文本段落,其次是更多,并在一个很好的图像下面。WordPress的:如何获得更多/摘录图像?

但是,摘录不会拍摄图像。

此外,如果我把更多的页面分割器,没有图像出现。即使是这样,“更多”链接应该在文本之后,而不是在图像之后。

我如何得到这个工作?

更新: 我注意到,在源代码中,有一个链接到图像,但它不是正确的链接。 目前我的博客位于www.domain.com/wordpress,将移至www.domain.com。

目前的图像具有代码:

<a href="../wp-content/uploads/2011/05/2010_06_01_archive.jpg"><img width="800" height="990" alt="" src="../wp-content/uploads/2011/05/2010_06_01_archive.jpg" title="2010_06_01_archive"></a> 

不知何故,内置的联动被打破

回答

5

使用WordPress的内置“功能的图像”(可交的编辑页面上的WordPress管理设置)。

在网页上显示的摘录:

<div id="excerpts"> 
    <?php 
    $args = array('numberposts' => 3, 'category'=> '1,3,5'); } 
    // set number of excepts to show 
    // and optionally restrict to certain categories 
    $posts = get_posts($args); 
    foreach($posts as $post) : setup_postdata($post); 
    ?> 
    <div class="single-excerpt"> 
     <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> 
     <?php if (has_post_thumbnail()) the_post_thumbnail('excerpt-thumb'); ?> 
     <!-- displays thumbnail if it exists --> 
     <p><?php the_excerpt();?></p> 
    </div><!-- single-excerpt --> 
    <?php endforeach; ?> 
</div><!-- excerpts --> 

在你的主题的的functions.php

if (function_exists('add_image_size')) add_theme_support('post-thumbnails'); 
if (function_exists('add_image_size')) { 
    add_image_size('excerpt-thumb', 0, 100, false); 
    // define excerpt-thumb size here 
    // in the example: 100px wide, height adjusts automatically, no cropping 
} 

function new_excerpt_length($length) { 
    return 42; 
    // define length of excerpt in number of words 
} 
add_filter('excerpt_length', 'new_excerpt_length'); 
+0

所以我可以有一个单独的主页上有多个职​​位,每个职位将有自己的特色图像,是吗? – mgPePe 2011-05-23 19:28:19

+0

是的,没错。上面的代码将产生完全的。只有'the_excerpt()'的警告是它没有格式化。如果你想要段落的文章摘录,你必须改用'the_content()'和'more'标签。 – 2011-05-23 20:16:55

+0

我将它标记为正确,但我想出了一个不同的方式:'add_theme_support('post-thumbnails');'在函数中,然后'<?php the_post_thumbnail();?>在循环中执行作业 – mgPePe 2011-05-27 13:46:46

-2

确保图像的大小合适,物理尺寸最小化,尽可能。 (GIF通常是这样做的最佳格式。)

http://codex.wordpress.org/Image_Size_and_Quality

+0

我不认为这是一个尺寸/质量问题。我添加了更多信息和源代码 – mgPePe 2011-05-23 12:50:40

+0

您是否尝试更新链接? – FluxEngine 2011-05-23 12:58:09

+0

我该怎么做? – mgPePe 2011-05-23 19:28:43