ADD new page acerca de la cnt

This commit is contained in:
2025-10-21 13:30:04 +00:00
parent e4a0634bc6
commit 8dd19a66dc
3 changed files with 180 additions and 15 deletions

View File

@@ -85,6 +85,18 @@ class StarterSite extends Site {
}, 10, 2);
/** FIN *************POST "QUÉ ES LA CNT" */
// archive-videos
add_action('pre_get_posts', function($query) {
if (!is_admin() && $query->is_main_query() && is_post_type_archive('videos')) {
$query->set('posts_per_page', 16);
$query->set('lang', '');
}
});
// 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']);
// *** SOLO USAR UNA VEZ PARA LIMPIAR. NO FUNCIONABA LA PAGINACIÓN DE SEARCH.
// add_action('init', function() {
// add_rewrite_rule(
@@ -309,7 +321,7 @@ class StarterSite extends Site {
}
}
}
return $polylang_data;
}
@@ -349,15 +361,16 @@ class StarterSite extends Site {
return $logos;
}
private function getPaginasAcerca() {
return Timber::get_posts([
'post_type' => 'acerca',
'post_status' => 'publish',
'orderby' => 'menu_order',
'order' => 'ASC',
'posts_per_page' => -1,
]);
}
// Recoge los posts del Post Type (ACF) Acerca
// private function getPaginasAcerca() {
// return Timber::get_posts([
// 'post_type' => 'acerca',
// 'post_status' => 'publish',
// 'orderby' => 'menu_order',
// 'order' => 'ASC',
// 'posts_per_page' => -1,
// ]);
// }
private function getDocumentos() {
@@ -371,7 +384,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 = [];
@@ -628,7 +641,50 @@ class StarterSite extends Site {
]) : [];
}
//Global variables
// Obtiene las subpaginas Acerca CNT
private function getSubpaginasAcercaCnt() {
$current_lang = pll_current_language(); // Detectar idioma actual
$page_slug = ($current_lang == 'eu') ? 'cnt-ri-buruz' : 'acerca-de-la-cnt';
$parent_page = get_page_by_path($page_slug);
if (!$parent_page) {
return [];
}
$args = array(
'post_type' => 'page',
'post_parent' => $parent_page->ID,
'orderby' => 'menu_order',
'order' => 'ASC',
'posts_per_page' => -1
);
return Timber::get_posts($args);
}
// Identifica el id de la Subpágina Acerca de la cnt.
public function get_page_content_ajax() {
$page_id = intval($_POST['page_id']);
if (!$page_id) {
wp_send_json_error('ID de página no válido');
}
$page = Timber::get_post($page_id);
if (!$page) {
wp_send_json_error('Página no encontrada');
}
wp_send_json_success([
'title' => $page->title,
'content' => apply_filters('the_content', $page->content)
]);
}
// *** Global variables ***
public function add_global_context($context) {
// GLobales
@@ -639,8 +695,8 @@ class StarterSite extends Site {
$context['footer_2'] = get_field('footer_text_2', 'option');
//Otras páginas
//$context['videos'] = $this->getVideos();
$context['paginas_acerca'] = $this->getPaginasAcerca();
$context['SubpaginasAcercaCnt'] = $this->getSubpaginasAcercaCnt();
//$context['paginas_acerca'] = $this->getPaginasAcerca();
$context['documentos'] = $this->getDocumentos();
$context['enlaces'] = $this->getEnlaces();
$context['contacto_info'] = $this->getContactoFields();