ADD pages conflictos laborales
This commit is contained in:
22
archive-conflictos-laborales.php
Normal file
22
archive-conflictos-laborales.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/**
|
||||
* Archive category 'Conflictos'
|
||||
*/
|
||||
global $params;
|
||||
$context = Timber::context();
|
||||
|
||||
// var_dump(get_cat_ID('Noticias'));
|
||||
$category = get_category_by_slug('conflictos');
|
||||
$ID_conflictos = 203;
|
||||
|
||||
$query = array(
|
||||
'post_type' => '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);
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* Category 'noticias'
|
||||
* Archive 'noticias'
|
||||
*/
|
||||
global $params;
|
||||
$context = Timber::context();
|
||||
@ -14,6 +14,7 @@ $query = array(
|
||||
'posts_per_page' => 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);
|
||||
18
archive.md
18
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.
|
||||
|
||||
|
||||
|
||||
@ -32,3 +32,19 @@ foreach(['/es/noticias/page/:paged','/eu/berriak/page/:paged'] as $route) {
|
||||
Routes::load('archive-noticias.php', $params, $query, 200);
|
||||
});
|
||||
}
|
||||
|
||||
// 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);
|
||||
});
|
||||
}
|
||||
|
||||
60
views/templates/page-conflictos-laborales.twig
Normal file
60
views/templates/page-conflictos-laborales.twig
Normal file
@ -0,0 +1,60 @@
|
||||
{% extends 'layouts/base.twig' %}
|
||||
|
||||
{% block content %}
|
||||
<h1 class="my-5 position-relative fs-3 fw-bold sp-module-title">{{ __('Conflictos Laborales', 'Sindikatua') }}</h1>
|
||||
|
||||
<section class="section-noticias">
|
||||
{% 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') %}
|
||||
|
||||
<div class="card my-3 position-relative posts-noticias">
|
||||
<div class="row g-0">
|
||||
<div class="col-md-4">
|
||||
<a href="{{ noticias.link }}" title="{{ noticias.title }}">
|
||||
<img src="{{ imagen }}"
|
||||
class="rounded-start object-fit-cover w-100 h-100 img-noticias"
|
||||
alt="{{ alt }}"
|
||||
/>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<div class="card-body" style="padding-bottom: 60px;">
|
||||
<a href="{{ noticias.link }}" title="{{ noticias.title }}" class="text-decoration-none card-title">
|
||||
<h5 class="card-title-text">{{ noticias.title }}</h5>
|
||||
</a>
|
||||
<p class="card-text"> {{
|
||||
noticias.excerpt({
|
||||
words: 50,
|
||||
read_more: ''
|
||||
})
|
||||
}}</p>
|
||||
<p class="card-text"><small class="text-body-secondary">{{ noticias.date }}</small></p>
|
||||
<a href="{{ noticias.link }}"
|
||||
class="btn position-absolute btn-secondary-cnt"
|
||||
style="position: absolute; bottom: 15px; right: 15px; z-index: 10;"
|
||||
>
|
||||
{{ __('Sigue leyendo', 'Sindikatua') }}...
|
||||
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<p>{{ __('No hay artículos', 'Sindikatua') }}</p>
|
||||
{% endif %}
|
||||
|
||||
<!-- PAGINATION -->
|
||||
{% set pagination = posts_conflictos.pagination %}
|
||||
<div class="pagination-custom mt-5">
|
||||
{% include 'partials/pagination-custom.twig' %}
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
{% endblock %}
|
||||
1
views/templates/page-lan-gatazkak.twig
Normal file
1
views/templates/page-lan-gatazkak.twig
Normal file
@ -0,0 +1 @@
|
||||
{% extends 'templates/conflictos-laborales.twig' %}
|
||||
Reference in New Issue
Block a user