>   

WordPress文章列表页面两种模式

wordpress文章列表页面两种模式,一种图文并茂、一种文章和描述的代码如下:

<article class="post">
            <?php if ( is_single() ) : // Only display full content for Single page ?>
            <span style="float:left;"> <strong>></strong> </span>
             <?php else: ?>
            <?php if(has_post_thumbnail()){ 
                                ?>
            <span  class="col-md-3" style="float:left;">
                <a  href="<?php the_permalink(); ?>" rel="external nofollow" class="external"  rel="external nofollow" class="external"  rel="external nofollow" class="external"  rel="external nofollow" class="external"  rel="external nofollow" class="external"  rel="external nofollow" class="external"  class="post-thumbnail" ><?php the_post_thumbnail(); ?></a>
            </span>
            <?php } ?>
            <?php endif; ?>
                <header class="entry-header">
                    <?php   
                        if ( is_single() ) :

                        the_title('<h1 class="entry-title">', '</h1>' );

                        else:

                        the_title( sprintf( '<h3 class="entry-title"><a href="%s" rel="external nofollow" class="external"  rel="bookmark">', esc_url( get_permalink() ) ), '</a></h3>' );

                        endif; 
                        ?>
                </header>
                <?php 
                if(($current_options['enable_post_meta']) == 'on') { ?>
                <div class="entry-meta">
                    <span class="entry-date"><a href="<?php the_permalink(); ?>" rel="external nofollow" class="external"  rel="external nofollow" class="external"  rel="external nofollow" class="external"  rel="external nofollow" class="external"  rel="external nofollow" class="external"  rel="external nofollow" class="external" ><time datetime=""><?php the_time('M j,Y');?></time></a></span>

                    <span class="comments-link"><a href="<?php the_permalink(); ?>" rel="external nofollow" class="external"  rel="external nofollow" class="external"  rel="external nofollow" class="external"  rel="external nofollow" class="external"  rel="external nofollow" class="external"  rel="external nofollow" class="external" ><?php  comments_popup_link( __( 'Leave a Reply', 'busiprof' ) ); ?></a></span>
                    <?php   $cat_list = get_the_category_list();
                                    if(!empty($cat_list)) { ?>
                    <span class="cat-links"><a href="<?php the_permalink(); ?>" rel="external nofollow" class="external"  rel="external nofollow" class="external"  rel="external nofollow" class="external"  rel="external nofollow" class="external"  rel="external nofollow" class="external"  rel="external nofollow" class="external" ><?php the_category(', '); ?></a></span>
                    <?php } if( get_the_tags() ) { ?>
                    <span class="tag-links"><a href="<?php the_permalink(); ?>" rel="external nofollow" class="external"  rel="external nofollow" class="external"  rel="external nofollow" class="external"  rel="external nofollow" class="external"  rel="external nofollow" class="external"  rel="external nofollow" class="external" ><?php the_tags('', ', ', ''); ?></a></span>
                    <?php } ?>
                </div>
                <?php } ?>

        <?php if ( is_single() ) : // Only display full content for Single page ?>
            <div class="entry-content">
                <?php
                    the_content( __( 'Read More', 'busiprof' ) );
                    wp_link_pages( array(
                        'before'      => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'busiprof' ) . '</span>',
                        'after'       => '</div>',
                        'link_before' => '<span>',
                        'link_after'  => '</span>',
                    ) );
                ?>
            </div><!-- .entry-content -->

            <?php else : ?>
            <div class="entry-summary">
                <?php the_excerpt(); ?>
            </div><!-- .entry-summary -->
            <?php endif; ?>





        </article>
        <!------------上一页下一页代码------------>
          <?php if ( is_single() ) : // Only display full content for Single page ?>
          <article  class="post">
            <?php
            $categories = get_the_category();
            $categoryIDS = array();
            foreach ($categories as $category) {
            array_push($categoryIDS, $category->term_id);
            }
            $categoryIDS = implode(",", $categoryIDS);
            ?>
            <p>
            <?php if (get_previous_post($categoryIDS)) { previous_post_link('上一篇: %link','%title',true);} else { echo "没有了,已经是最后文章";} ?>
            </p>
            <p>
            <?php if (get_next_post($categoryIDS)) { next_post_link('下一篇: %link','%title',true);} else { echo "没有了,已经是最新文章";} ?>
            </p>
            </article>
        <?php endif; ?>
        <!-----------------相关文章代码------------------->
             <?php
        if ( is_single() ) :
        global $post;
        $categories = get_the_category();
        foreach ($categories as $category) :
            ?>
            <article  class="post">

                <h4 class="entry-title">相关文章</h4>
                <?php
                $posts = get_posts('numberposts=5&category='. $category->term_id.'&exclude='.get_the_ID());
                foreach($posts as $post) :
                ?>
                <ul>
                    <li>
                    <a href="<?php the_permalink(); ?>" rel="external nofollow" class="external"  rel="external nofollow" class="external"  rel="external nofollow" class="external"  rel="external nofollow" class="external"  rel="external nofollow" class="external"  rel="external nofollow" class="external" ><?php the_title(); ?></a>
                    </li>
                    </ul>
                <?php endforeach; ?>

          </article>  
        <?php
        endforeach; endif ; ?>

要发表评论,您必须先登录