Loading...
That's it!
No more pages to load
add_filter('the_content', function ($content) {
if (is_admin() || !is_page() || !in_the_loop() || !is_main_query()) return $content;
$parent = get_page_by_path('playlists');
$current = get_post();
if (!$parent || !$current || (int) $current->post_parent !== (int) $parent->ID) return $content;
$siblings = get_pages(array(
'parent' => $parent->ID,
'sort_column' => 'menu_order,post_title',
'post_status' => 'publish',
));
$ids = wp_list_pluck($siblings, 'ID');
$total = count($ids);
$i = array_search($current->ID, $ids);
if ($i === false || $total < 2) return $content;
$prev_id = $ids[($i - 1 + $total) % $total];
$next_id = $ids[($i + 1) % $total];
$html = '';
return $content . $html;
});