1

我想添加几个图像和 div 并自定义我的博客文章列表的外观......但我找不到这样做的方法。

这是博客模板代码

<?php
/*
 WARNING: This file is part of the core Genesis framework. DO NOT edit
 this file under any circumstances. Please do all modifications
 in the form of a child theme.
 */

/**
 * Template Name: Blog
 * This file handles blog post listings within a page.
 *
 * This file is a core Genesis file and should not be edited.
 *
 * The blog page loop logic is located in lib/structure/loops.php
 *
 * @category Genesis
 * @package  Templates
 * @author   StudioPress
 * @license  http://www.opensource.org/licenses/gpl-license.php GPL v2.0 (or later)
 * @link     http://www.studiopress.com/themes/genesis
 */
genesis();

就在genesis();代码上方.. 我试图在那里放一些 div 和图像.. 但我想这不是它的工作方式。..

我还尝试使用普通的 wordpress 代码主题制作自己的博客列表模板。

<?php /* 
Template Name: List Post Pages
*/ 
?>
<?php get_header(); ?>
<?php if ( has_post_thumbnail() ) { ?>

<div class="featured">
  <?php the_post_thumbnail(); ?>
</div>
<?php } ?>
<div class="divider"></div>
<div id="content" class="hfeed">
  <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
  <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
    <h2><a href="<?php the_permalink() ?>">
      <?php the_title(); ?>
      </a></h2>
    <div class="entry">
      <?php the_content(); ?>
    </div>
    <div class="postmetadata">
      <?php the_tags('Tags: ', ', ', '<br />'); ?>
      Posted in
      <?php the_category(', ') ?>
      |
      <?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?>
    </div>
  </div>
  <?php endwhile; ?>
  <?php else : ?>
  <h2>Not Found</h2>
  <?php endif; ?>
  <?php genesis_after_loop(); ?>
</div>
<?php get_footer(); ?>

但是没有运气,这样做的正确方法是什么?

***更新-下面的代码是我想要的..但​​没有页面的内容。我想要带有摘录的帖子列表....我该怎么做????

<?php /*
Template Name: Page Template
*/ ?>
<?php get_header(); ?>
<?php if ( has_post_thumbnail() ) { ?>

<div class="featured">
  <?php the_post_thumbnail(); ?>
</div>
<?php } ?>
<div class="divider"></div>
<?php genesis_before_content_sidebar_wrap(); ?>
<div id="content-sidebar-wrap">
  <?php genesis_before_content(); ?>
  <div id="content" class="hfeed">
    <?php genesis_before_loop(); ?>
    <?php genesis_loop(); ?>
    <?php genesis_after_loop(); ?>
  </div>
  <!-- end #content -->
  <?php genesis_after_content(); ?>
</div>
<!-- end #content-sidebar-wrap -->
<?php genesis_after_content_sidebar_wrap(); ?>
<?php get_footer(); ?>
4

1 回答 1

2

令我震惊的是没有人回答我的问题..无论如何,如果有人遇到类似问题的帖子。答案是添加

<?php query_posts( $args );  ?>

就在上面<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

总而言之,我的代码看起来像这样......

<?php /*
Template Name: Page Template
*/ ?>
<?php get_header(); ?>
<?php if ( has_post_thumbnail() ) { ?>

<div class="featured">
  <?php the_post_thumbnail(); ?>
</div>
<?php } ?>
<div class="divider"></div>
<?php genesis_before_content_sidebar_wrap(); ?>
<div id="content-sidebar-wrap">
  <?php genesis_before_content(); ?>
  <div id="content" class="hfeed">
    <?php genesis_before_loop(); ?>
    <?php query_posts( $args );  ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
      <h2><a href="<?php the_permalink() ?>">
        <?php the_title(); ?>
        </a></h2>
      <div class="entry">
        <?php the_content(); ?>
      </div>
      <div class="postmetadata">
        <?php the_tags('Tags: ', ', ', '<br />'); ?>
        Posted in
        <?php the_category(', ') ?>
        |
        <?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?>
      </div>
    </div>
    <?php endwhile; ?>
    <?php else : ?>
    <h2>Not Found</h2>
    <?php endif; ?>
    <?php genesis_after_loop(); ?>
  </div>
  <!-- end #content -->
  <?php genesis_after_content(); ?>
</div>
<!-- end #content-sidebar-wrap -->
<?php genesis_after_content_sidebar_wrap(); ?>
<?php get_footer(); ?>
于 2013-08-01T21:34:13.877 回答