猿问

Ajax加载更多后的类别标题超出了<a> </a>

我添加了一段显示当前条目类别的代码。在正常加载下,一切都很好,但是通过单击更多加载(使用AJAX),类别名称会超出。有什么问题?


?>

<div class="kategoria-wpisy">

    <?php 

    $category = get_the_category(); 


    if (!empty($category)) {

        $category_id = get_cat_ID( $category[0]->cat_name );

        echo "<a href=". get_category_link( $category_id ) . ">" . $category[0]->cat_name . "</a>"; 

    }


    ?>

</div>

加载后,更多内容必须与以前相同。


皈依舞
浏览 105回答 1
1回答

有只小跳蛙

查看您的Ajax请求,您在href属性周围的引号有问题。试试这个:<div class="kategoria-wpisy">&nbsp; &nbsp; <?php&nbsp;&nbsp; &nbsp; $category = get_the_category();&nbsp;&nbsp; &nbsp; if (!empty($category)) {&nbsp; &nbsp; &nbsp; &nbsp; $category_id = get_cat_ID( $category[0]->cat_name );&nbsp; &nbsp; &nbsp; &nbsp; echo '<a href="'. get_category_link( $category_id ) . '">' . $category[0]->cat_name . '</a>';&nbsp;&nbsp; &nbsp; }&nbsp; &nbsp; ?></div>
随时随地看视频慕课网APP
我要回答