Wordpress博客中的第一篇文章显示不正确

时间:2013-02-15 01:51:41

标签: wordpress

我正在构建一个wordpress主题,而顶级博客帖子总是显示不正确。代码在这里:

    <div class="bordered centered">
    <p class="negative-margin alignleft header"><?php the_title(); ?></p><p class="negative-margin alignright date"><?php the_date(); ?></p><div style="clear:both;"></div>
    <?php if ( is_search() ) : // Only display Excerpts for Search ?>
    <div class="entry-summary">
        <?php the_excerpt(); ?>
    </div><!-- .entry-summary -->
<?php else : ?>
<div class="entry-content">
    <?php if ( has_post_thumbnail() ):?>
    <div id="entry-left"><?php   $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'large');
    echo '<a href="' . $large_image_url[0] . '" title="' . the_title_attribute('echo=0') . '" >';
    echo get_the_post_thumbnail($post->ID, 'large'); 
    echo '</a>';?>
</div>
<div class="entry-right">
    <?php the_content( __( 'More <span class="meta-nav">&rarr;</span>', 'huckleberry' ) ); ?>
    <?php wp_link_pages( array( 'before' => '<div class="page-links">' . __( 'Pages:', 'huckleberry' ), 'after' => '</div>' ) ); ?>
</div>
<div class="entry-right">
    <table>
        <tr>
            <td><p class="header">Details</p><br />
                <?php $my_meta = get_post_meta( $post->ID, 'link', false ); ?>
                <?php if ($my_meta): var_dump($my_meta) ?>
                <?php foreach ($my_meta as $currMeta): ?>
                <?php if( $currMeta && '' != $currMeta ): $currMeta=explode($currMeta,";",2);?>
                     <a href="<?php echo $my_meta[1] ?>"><?php $my_meta[0];?></a>
                <?php endif; endforeach; endif; ?>
            </td>
            <td>
                 <a href="<?php echo MultiPostThumbnails::get_post_thumbnail_url(get_post_type(), 'secondary-image');?>">
                <?php if (class_exists('MultiPostThumbnails')) : MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'secondary-image'); endif; ?>
                </a>
            </td>
            <td>
                 <a href="<?php echo MultiPostThumbnails::get_post_thumbnail_url(get_post_type(), 'tertiary-image');?>">
                    <?php if (class_exists('MultiPostThumbnails')) : MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'tertiary-image'); endif; ?>
                 </a>
            </td>
            <td>
                 <a href="<?php echo MultiPostThumbnails::get_post_thumbnail_url(get_post_type(), 'fourth-image');?>">
                 <?php if (class_exists('MultiPostThumbnails')) : MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'fourth-image'); endif; ?>
                </a>
            <td>
        </tr>
     </table>
</div>

使用相关的CSS:

.alignleft {
float:left;
}
.alignright {
float:right;
}
.bordered {
border:2px solid black;
}
.negative-margin {
margin-top:-25px;
margin-left:5px;
background:white;
}
.header {
font-size:200%;
}
.date {
font-size:150%;
}
.centered {
width:640px;
margin-left:auto;
margin-right:auto;
}
#entry-left {
float:left;
width:200px;
}
.entry-right {
    float:right;
width:430px;
}

所有其他帖子都有边框,边框上标题和日期,但顶部帖子的边框覆盖标题,如下所示:http://imgur.com/6pE79ro

我对Wordpress相对较新,似乎无法弄清楚这里发生了什么。

另外,我正在尝试使用自定义字段来显示“详细信息”下的链接。这个想法是让链接的密钥始终是“链接”,并且值的格式为“description; url”,这样我就可以将值分解为两个值,以便显示链接描述和URL。我无法实现显示任何链接。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:1)

也许无关紧要,但你在哪里关闭以下div? <div class="bordered centered"><div id="entry-left">

这并不能完全回答你的第二个问题,但对于自定义字段:我建议使用一个很棒的WP模块 - ACF。它允许您轻松创建和读取自定义创建字段的值,并提供更多有用的功能。该插件可在此处找到:http://wordpress.org/extend/plugins/advanced-custom-fields/