ADD redirect acerca de la cnt
This commit is contained in:
@@ -96,7 +96,8 @@ class StarterSite extends Site {
|
||||
// Handler AJAX para cargar contenido de páginas
|
||||
add_action('wp_ajax_get_page_content', [$this, 'get_page_content_ajax']);
|
||||
add_action('wp_ajax_nopriv_get_page_content', [$this, 'get_page_content_ajax']);
|
||||
|
||||
add_action('template_redirect', [$this, 'redirect_subpaginas_acerca']);
|
||||
|
||||
// *** SOLO USAR UNA VEZ PARA LIMPIAR. NO FUNCIONABA LA PAGINACIÓN DE SEARCH.
|
||||
// add_action('init', function() {
|
||||
// add_rewrite_rule(
|
||||
@@ -384,7 +385,7 @@ class StarterSite extends Site {
|
||||
]);
|
||||
|
||||
$posts = Timber::get_posts($args);
|
||||
error_log('✅ Número de posts "Documentos" encontrados: ' . count($posts));
|
||||
//error_log('✅ Número de posts "Documentos" encontrados: ' . count($posts));
|
||||
|
||||
$documentos = [];
|
||||
|
||||
@@ -664,7 +665,7 @@ class StarterSite extends Site {
|
||||
|
||||
}
|
||||
|
||||
// Identifica el id de la Subpágina Acerca de la cnt.
|
||||
// Identifica el id de la Subpágina "Acerca de la cnt"
|
||||
public function get_page_content_ajax() {
|
||||
$page_id = intval($_POST['page_id']);
|
||||
|
||||
@@ -680,10 +681,40 @@ class StarterSite extends Site {
|
||||
|
||||
wp_send_json_success([
|
||||
'title' => $page->title,
|
||||
'content' => apply_filters('the_content', $page->content)
|
||||
'content' => apply_filters('the_content', $page->content),
|
||||
'url' => get_permalink($page_id) // Añade la URL de la página
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
// Redirige a las subpaginas de "Acerca de la cnt"
|
||||
public function redirect_subpaginas_acerca() {
|
||||
if (!is_page()) {
|
||||
return;
|
||||
}
|
||||
|
||||
global $post;
|
||||
|
||||
// Obtener las páginas padre (español y euskera)
|
||||
$parent_es = get_page_by_path('acerca-de-la-cnt');
|
||||
$parent_eu = get_page_by_path('cnt-ri-buruz');
|
||||
|
||||
$parent_ids = array_filter([
|
||||
$parent_es ? $parent_es->ID : null,
|
||||
$parent_eu ? $parent_eu->ID : null
|
||||
]);
|
||||
|
||||
// Si es una subpágina de "Acerca de la CNT"
|
||||
if ($post->post_parent && in_array($post->post_parent, $parent_ids)) {
|
||||
// Redirigir a la página padre con el ID de la subpágina
|
||||
$parent_url = get_permalink($post->post_parent);
|
||||
$redirect_url = add_query_arg('subpage', $post->ID, $parent_url);
|
||||
|
||||
wp_redirect($redirect_url, 301);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// *** Global variables ***
|
||||
public function add_global_context($context) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user