我有一个自定义WP_Query:
$args = array(
'category_name' => 'direct-naar',
'post_type' => array( 'page', 'post' ),
'post_status' => 'publish',
);
$directNaarPosts = new WP_Query( $args );
?>
<section id="side-direct_naarlist" class="widget widget_text">
<div class="widget-wrap">
<h4 class="widget-title widgettitle">Direct naar:</h4>
<div class="category-direct-naar"><?php
if( $directNaarPosts->have_posts() ):
while( $directNaarPosts->have_posts() ): $directNaarPosts->the_post();
$title = get_the_title();
$permalink = get_permalink();
?>
<a href="<?php echo $permalink; ?>" title="Ga naar <?php echo $title;?>">
<?php echo $title; ?>
</a>
<?php
endwhile;
endif;
wp_reset_postdata();
echo '</div></div></section>';
产生以下代码:
<div class="category-direct-naar"><a>
</a><a href="http://wp.kndb.nl/damclub-zoeken/#damclub-zoeken">Damclub zoeken</a>
<a href="http://wp.kndb.nl/nationale-competitie/#nationale-competitie">Nationale competitie</a>
<a href="http://wp.kndb.nl/downloads/#downloads">Downloads</a>
<a href="http://wp.kndb.nl/damclubs-nl/#damclubs-nl">Damclubs NL</a>
<a href="http://wp.kndb.nl/damkalender/#damkalender">Damkalender</a>
</div>
另见右侧边栏:http://wp.kndb.nl/category/sport/
<div class="category-direct-naar">
之后有一个空的锚标记。我不知道这个锚标签来自哪里。
有人可以帮我解决这个烦人的问题吗?
答案 0 :(得分:0)
我找到了这个问题的解决方案。在上面这个查询的HTML代码中,我以错误的方式关闭了一个锚标签:-(。这导致了问题。也许这对将来有人有帮助