详情翻页

2023-12-25 3次

<div class="detail-nextpage">
    <div class="container">
    <ul>
        <?php
        $categories = get_the_category();
        $categoryIDS = array();
        foreach ($categories as $category) {
            array_push($categoryIDS, $category->term_id);
        }
        $categoryIDS = implode(",", $categoryIDS);
        if (get_next_post($categoryIDS)) { ?>
            <li>
                <h3>下一篇</h3>
                <?php next_post_link('%link', '%title', true);?>
            </li>
        <?php } else { ?>
        <li>
            <h3>下一篇</h3>
            <a href="javascript:;"><?php echo "End";?></a>
        </li>
        <?php }
        if (get_previous_post($categoryIDS)) { ?>
        <li>
            <h3>下一篇</h3>
            <?php previous_post_link('%link', '%title', true);?>
        </li>
        <?php } else {?>
        <li>
            <h3>下一篇</h3>
            <a href="javascript:;"><?php echo "End";?></a>
        </li>
        <?php } ?>
        </ul>
    </div>
</div>