wordpress实现文章页上一篇/下一篇功能

时间:2024-04-01 12:00:13

wordpress实现文章页上一篇/下一篇功能

<?php
                        $categories = get_the_category(); 
                        $categoryIDS = array();
                        foreach ($categories as $category) {
                            array_push($categoryIDS, $category->term_id);
                        }
                        $categoryIDS = implode(",", $categoryIDS);
                    ?>
                    <?php if (get_previous_post($categoryIDS)) { previous_post_link('上一篇: %link','%title',true);} else { echo "";} ?>
                    <br/>
                    <?php if (get_next_post($categoryIDS)) { next_post_link('下一篇: %link','%title',true);} else { echo "";} ?>