我有几个类别,其中之一是“旅行”每个帖子都包含一个关于旅行的小简介。我如何显示一个分类页面,显示每个帖子的标题和简历?
我正在编辑的网站是:http://thestudentbubble.com/trips-away/
目前我有以下代码:
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <?php if ( is_sticky() && is_home() && ! is_paged() ) : ?>
    <div class="featured-post">
        <?php _e( 'Featured post', 'twentytwelve' ); ?>
    </div>
    <?php endif; ?>
    <header class="entry-header">
        <div class="scale"><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a></div>
        <div class="content-list">
            <h1 class="entry-title">
                <a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a>
            </h1>
            <?php if(!in_category( array( 10,12,13 ) )){ if(function_exists('the_ratings')) { the_ratings(); } } ?>
            <?php // the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentytwelve' ) ); ?>
                    <div class="decent-comments">
<ul>
    <li>
            <div class="comment">
<?php
$cats = get_the_category();
$category_id = $cats[0]->cat_ID;
$args = array( 'posts_per_page' => 1, 'category' => $category_id);
$lastposts = get_posts( $args );
foreach ( $lastposts as $post ) :
  setup_postdata( $post ); ?>
<?php the_content("Continue reading " . the_title('', '', false)); ?>
<?php endforeach; 
 wp_reset_postdata(); ?>
            </div>
        </li>
</ul>
</div>
    <?php wp_link_pages( array( 'before' => '<div class="page-links">' . __( 'Pages:', 'twentytwelve' ), 'after' => '</div>' ) ); ?>
        </div>
            <div class="clear"></div>
    </header><!-- .entry-content -->
</article><!-- #post -->发布于 2014-05-15 23:37:19
$c = "xfgnx dfbdf dsfbdfb";
$charLimit = 5;
echo strlen ($c);
echo "<br>";
echo substr($c, $charLimit);这应该会有帮助
https://stackoverflow.com/questions/23682639
复制相似问题