【问题标题】:3 column layout wordpress (3 posts on a page)3 列布局 wordpress(一页 3 个帖子)
【发布时间】:2013-07-08 23:01:30
【问题描述】:

我的客户希望他的新闻页面上有 3 列和 3 个帖子。

每一栏都有标题名称、日期、摘录和阅读更多功能。

像这样:http://rikvandoorn.nl/nieuws_pagina.jpg

因为我的 PHP 知识不是很好,我一直在寻找一些教程来创建 3 列页面。但是所有这些教程都已过时,缺乏信息,或者似乎效果不佳。

并且“留言回复”可以移到single.php中。

所以我希望你们中的一些人能给我一些帮助。

这是我当前的内容.php

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
        <div class="aside">
            <h1 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'twentytwelve' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h1>
            <div class="entry-content">
                <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentytwelve' ) ); ?>
            </div><!-- .entry-content -->
        </div><!-- .aside -->

        <footer class="entry-meta">
            <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'twentytwelve' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php echo get_the_date(); ?></a>
            <?php if ( comments_open() ) : ?>
            <div class="comments-link">
                <?php comments_popup_link( '<span class="leave-reply">' . __( 'Leave a reply', 'twentytwelve' ) . '</span>', __( '1 Reply', 'twentytwelve' ), __( '% Replies', 'twentytwelve' ) ); ?>
            </div><!-- .comments-link -->
            <?php endif; // comments_open() ?>
            <?php edit_post_link( __( 'Edit', 'twentytwelve' ), '<span class="edit-link">', '</span>' ); ?>
        </footer><!-- .entry-meta -->
    </article><!-- #post -->

【问题讨论】:

  • 你的 CSS 是什么样的?您只是在问如何将页面样式设置为您链接到的图像?
  • 设置页面样式似乎并不难。我正在寻找的是创建该布局所需的 php 脚本(在 functions.php 中),因此每次添加新帖子时,只有布局会更新内容。有多个页面的可能性

标签: php css html wordpress multiple-columns


【解决方案1】:

设置wordpressloop

<?php if ( have_posts() ) :  while ( have_posts() ) : the_post();?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
        <div class="aside">
            <h1 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'twentytwelve' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h1>
            <div class="entry-content">
                <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentytwelve' ) ); ?>
            </div><!-- .entry-content -->
        </div><!-- .aside -->
            <?php edit_post_link( __( 'Edit', 'twentytwelve' ), '<span class="edit-link">', '</span>' ); ?>
    </article><!-- #post -->
<?php endwhile; endif; wp_reset_query(); ?>

然后在管理员中转到设置>常规>阅读-在“博客页面最多显示”中选择3

【讨论】:

    猜你喜欢
    • 2014-01-24
    • 2012-01-26
    • 2013-10-01
    • 1970-01-01
    • 2014-07-22
    • 1970-01-01
    • 1970-01-01
    • 2013-08-21
    • 2019-11-18
    相关资源
    最近更新 更多