php
function my_custom_nav() {
global $post;
// Obtén el ID del padre
$parent_id = wp_get_post_parent_id($post->ID);
if ($parent_id) {
// Obtén las subpáginas del padre
$children = get_children(array('post_parent' => $parent_id, 'post_type' => 'page', 'orderby' => 'menu_order', 'order' => 'ASC'));
$children_ids = wp_list_pluck($children, 'ID');
$current_index = array_search($post->ID, $children_ids);
if ($current_index !== false) {
// Botón anterior
if ($current_index > 0) {
$prev_post = get_post($children_ids[$current_index - 1]);
echo '<a href="' . get_permalink($prev_post->ID) . '">Anterior: ' . $prev_post->post_title . '</a>';
}
// Botón siguiente
if ($current_index < count($children_ids) - 1) {
$next_post = get_post($children_ids[$current_index + 1]);
echo '<a href="' . get_permalink($next_post->ID) . '">Siguiente: ' . $next_post->post_title . '</a>';
}
}
}
}
add_action('wp_footer', 'my_custom_nav');