drzil26260 2015-09-07 14:51
浏览 27

博客列表页面中的Wordpress 2列

I have been searching for hours, trying to figure out how to display blog posts in 2 columns on the blog page in a wordpress website i am working on.

WP version is 4.3

The php file to render the blog post listings is templates/posts.php

I am trying to figure out how to modify this file to show a simple 2 column layout. I am not fussy as to how it is displayed. If someone can point me in the right direction or give me some pointers on the easiest way. That would be great.

Thanks in advance,

Here is the templates/posts.php file..

<?php

$page_total = $wp_query->max_num_pages;
$page_number = max(1, get_query_var('paged'));
$paging = blog_paging($page_number, $page_total);

$html = $paging;
while(have_posts()) {
    the_post();
    $html .= tabs(3).'<article id="post-'.$post->ID.'">'.PHP_EOL;
    $html .= tabs(4).'<header>'.PHP_EOL;
    $html .= tabs(5).'<h2><a href="'.get_permalink($post->ID).'">'.$post->post_title.'</a></h2>'.PHP_EOL;
    $html .= tabs(5).'<ul class="meta">'.PHP_EOL;
    $html .= tabs(6).'<li>'.get_comments_popup_link(__('Leave a comment', 'allsorters'), __('1 Comment', 'allsorters'), __('% Comments', 'allsorters'), 'comments').'</li>'.PHP_EOL;
    $html .= tabs(6).'<li><time datetime="'.$post->post_date.'">'.get_the_time(get_option('date_format')).'</time></li>'.PHP_EOL;
    $html .= tabs(6).'<li><em>by</em> '.get_the_author().'</li>'.PHP_EOL;
    //$html .= tabs(6).'<li>Posted in: '.get_the_category_list(', ').'</li>'.PHP_EOL;
    if(current_user_can('manage_options')) $html .= tabs(6).'<li class="button-edit-post"><a href="'.get_edit_post_link($post->ID).'">Edit</a></li>'.PHP_EOL;
    $html .= tabs(5).'</ul>'.PHP_EOL;
    $html .= tabs(4).'</header>'.PHP_EOL;
    $html .= tabs(4).'<div class="content">'.PHP_EOL;
    $html .= tabs(5).apply_filters('the_content', get_the_excerpt());
    $html .= tabs(4).'</div>'.PHP_EOL;
    $html .= tabs(3).'</article>'.PHP_EOL;
}
$html .= '<br />'.$paging;
echo $html;
?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥50 安卓adb backup备份子用户应用数据失败
    • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
    • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
    • ¥30 python代码,帮调试
    • ¥15 #MATLAB仿真#车辆换道路径规划
    • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
    • ¥15 数据可视化Python
    • ¥15 要给毕业设计添加扫码登录的功能!!有偿
    • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
    • ¥15 微信公众号自制会员卡没有收款渠道啊