From 10dbf60c80e5fea623acec7fe8137c8af3a9be8e Mon Sep 17 00:00:00 2001 From: gustavo Date: Mon, 20 Oct 2025 09:09:04 +0000 Subject: [PATCH] ADD pages conflictos laborales --- archive-conflictos-laborales.php | 22 +++++++ archive-noticias.php | 5 +- archive.md | 20 ++++++- functions.php | 18 +++++- .../templates/page-conflictos-laborales.twig | 60 +++++++++++++++++++ views/templates/page-lan-gatazkak.twig | 1 + 6 files changed, 121 insertions(+), 5 deletions(-) create mode 100644 archive-conflictos-laborales.php create mode 100644 views/templates/page-conflictos-laborales.twig create mode 100644 views/templates/page-lan-gatazkak.twig diff --git a/archive-conflictos-laborales.php b/archive-conflictos-laborales.php new file mode 100644 index 0000000..a44f464 --- /dev/null +++ b/archive-conflictos-laborales.php @@ -0,0 +1,22 @@ + 'post', + 'cat' => $category ? $category->term_id : $ID_conflictos, + 'paged' => isset($params['paged']) ? $params['paged'] : 1, + 'posts_per_page' => get_option('posts_per_page') // Usa la configuración de WordPress + ); +$context['posts_conflictos'] = Timber::get_posts($query); +error_log('✅ archive-conflictos-laborales.php'); +//error_log('✅ archive-conflictos-laborales.php - Posts: ' . count($context['posts_conflictos'])); + +Timber::render('templates/page-conflictos-laborales.twig', $context); \ No newline at end of file diff --git a/archive-noticias.php b/archive-noticias.php index 36e9256..970e826 100644 --- a/archive-noticias.php +++ b/archive-noticias.php @@ -1,6 +1,6 @@ get_option('posts_per_page') // Usa la configuración de WordPress ); $context['posts_noticias'] = Timber::get_posts($query); -error_log('✅ category-noticias.php - Posts: ' . count($context['posts_noticias'])); +error_log('✅ archive-noticias.php - Posts: ' . count($context['posts_noticias'])); +// error_log('✅ archive-noticias.php - Posts: ' . count($context['posts_noticias'])); Timber::render('templates/page-noticias.twig', $context); \ No newline at end of file diff --git a/archive.md b/archive.md index 4fe51bf..865e01a 100644 --- a/archive.md +++ b/archive.md @@ -1,3 +1,6 @@ +========================== +========================== +ARCHIVE PARA POST TYPE CREADOS Idiomas > Ajustes > post type: marcar el post type. @@ -12,11 +15,24 @@ Crear archive-slug.php (Ej: archive-videos.php) Si se quieren recibir todos los posts, independientemente del idioma. Ejemplo: -$context['videos'] = Timber::get_posts([ +> $context['videos'] = Timber::get_posts([ 'post_type' => 'videos', 'posts_per_page' => -1, 'lang' => '' // Importante: vacío para obtener todos -]); + ]); +========================== ========================== +========================== +========================== +ARCHIVE PARA CATEGORIAS + +> Ir a functions.php y añadir rutas (para cada idioma) +> Crear archive-slug.php +> Crear página (para cada idioma) +> Crear page-slug.twig (para cada idioma) +> Añadir en el menú como "Enlaces personalizados" (para cada idioma) +> +> ¡OJO en el menú! Hay que ver si es subelemento para poner la ruta bien en el functions. + diff --git a/functions.php b/functions.php index 38dc666..c7f3e56 100644 --- a/functions.php +++ b/functions.php @@ -31,4 +31,20 @@ foreach(['/es/noticias/page/:paged','/eu/berriak/page/:paged'] as $route) { $query = false; Routes::load('archive-noticias.php', $params, $query, 200); }); -} \ No newline at end of file +} + +// Ruta para la página de 'Conflictos laborales' +foreach(['/es/noticias/conflictos-laborales','/eu/berriak/lan-gatazkak'] as $route) { + Routes::map($route, function($params){ + $query = false; + Routes::load('archive-conflictos-laborales.php', $params, $query, 200); + }); +} + +// Ruta para las páginas de paginación 'Conflictos laborales' +foreach(['/es/noticias/conflictos-laborales/page/:paged','/eu/berriak/lan-gatazkak/page/:paged'] as $route) { + Routes::map($route, function($params){ + $query = false; + Routes::load('archive-conflictos-laborales.php', $params, $query, 200); + }); +} diff --git a/views/templates/page-conflictos-laborales.twig b/views/templates/page-conflictos-laborales.twig new file mode 100644 index 0000000..6aee229 --- /dev/null +++ b/views/templates/page-conflictos-laborales.twig @@ -0,0 +1,60 @@ +{% extends 'layouts/base.twig' %} + +{% block content %} +

{{ __('Conflictos Laborales', 'Sindikatua') }}

+ +
+ {% if posts_conflictos %} + {% for noticias in posts_conflictos %} + + {% set imagen = noticias.thumbnail.src | default('/wp-content/uploads/2025/10/Imagen_por_defecto_300.jpg') %} + {% set alt = noticias.thumbnail.alt | default('Imagen por defecto') %} + +
+
+
+ + {{ alt }} + +
+
+
+ +
{{ noticias.title }}
+
+

{{ + noticias.excerpt({ + words: 50, + read_more: '' + }) + }}

+

{{ noticias.date }}

+ + {{ __('Sigue leyendo', 'Sindikatua') }}... + + +
+
+
+
+ + {% endfor %} + {% else %} +

{{ __('No hay artículos', 'Sindikatua') }}

+ {% endif %} + + + {% set pagination = posts_conflictos.pagination %} +
+ {% include 'partials/pagination-custom.twig' %} +
+ +
+ +{% endblock %} diff --git a/views/templates/page-lan-gatazkak.twig b/views/templates/page-lan-gatazkak.twig new file mode 100644 index 0000000..7032129 --- /dev/null +++ b/views/templates/page-lan-gatazkak.twig @@ -0,0 +1 @@ +{% extends 'templates/conflictos-laborales.twig' %} \ No newline at end of file