作为一个Wordpress新手,我目前正在整理一个基于网络链接的模板,该链接将在他们所在类别的单个页面上显示我的所有博客文章。不幸的是,无论我如何修补定义列表,格式似乎不起作用。
有谁知道为什么以下代码无法响应我的DL?实际页面的链接是http://gameservertutorials.com/?page_id=2
<?php
/*
Template Name: Group Archives
*/
?>
<?php get_header(); ?>
<div id="content">
<?php
$cat_args = array(
'orderby' => 'name',
'order' => 'ASC',
'child_of' => 0
);
$categories = get_categories($cat_args);
?>
<div class="post">
<dl>
<?php foreach($categories as $category){ ?>
<div class="title">
<dt><h2><a href="<?php echo get_category_link( $category->term_id ) ?>" title="<?php echo sprintf( __( "View all posts in %s" ), $category->name ) ?>"><?php echo $category->cat_name ?></a></h2></dt>
</div>
<?php
$post_args = array(
'numberposts' => 50,
'category' => $category->term_id
);
$posts = get_posts($post_args);
foreach($posts as $post){
?>
<dd><a href="<?php echo the_permalink(); ?>" title="<?php echo the_title(); ?>"><?php echo the_title(); ?></a></dd>
<?php
}
?>
<?php
}
?>
</dl>
</div>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
答案 0 :(得分:0)
尝试从<dt>
标记中删除周围的DIV:
<dt class="title"><h2><a href="<?php echo get_category_link( $category->term_id ) ?>" title="<?php echo sprintf( __( "View all posts in %s" ), $category->name ) ?>"><?php echo $category->cat_name ?></a></h2></dt>