ADD archive-videos

This commit is contained in:
2025-10-16 11:26:27 +00:00
parent 2f6b47a576
commit 9abdf1249d
8 changed files with 56 additions and 74 deletions

View File

@@ -57,10 +57,9 @@ class StarterSite extends Site {
return $classes;
}, 10, 3);
// Añadir estilo en el admin
// Añadir estilo en el admin a los "ids_especiales"
add_action('admin_head', function() use ($ids_especiales) {
if (empty($ids_especiales)) return;
$css = '';
foreach ($ids_especiales as $id) {
$css .= "tr#post-$id td { background-color: #fffae6 !important; border-top: 2px solid #f0c000 !important; }";
@@ -86,29 +85,6 @@ class StarterSite extends Site {
}, 10, 2);
/** FIN *************POST "QUÉ ES LA CNT" */
// ***************TEMP: Debug archivo vídeos
// add_action('template_redirect', function() {
// global $wp_query;
// error_log('🔍 Template: ' . get_query_var('post_type'));
// error_log('🔍 Is post type archive: ' . (is_post_type_archive() ? 'YES' : 'NO'));
// error_log('🔍 Post type archive: ' . (is_post_type_archive('videos') ? 'VIDEOS' : 'NO'));
// });
// add_action('init', function() {
// add_rewrite_rule(
// '(eu|es)/videos/?$',
// 'index.php?lang=$matches[1]&post_type=videos',
// 'top'
// );
// add_rewrite_rule(
// '(eu|es)/videos/page/([0-9]{1,})/?$',
// 'index.php?lang=$matches[1]&post_type=videos&paged=$matches[2]',
// 'top'
// );
// });
// ******************************************
parent::__construct();
}
@@ -308,6 +284,17 @@ class StarterSite extends Site {
$polylang_data['home_urls'][$lang['slug']] = $lang['url'];
}
}
// Si no hay videos en euskera, el botón euskera no detecta videos en ese idioma y te lleva a la home.
if (is_post_type_archive('videos')) {
foreach ($polylang_data['languages'] as $slug => &$lang) {
if ($slug === 'es') {
$lang['url'] = home_url('/es/videos/');
} elseif ($slug === 'eu') {
$lang['url'] = home_url('/eu/bideoak/');
}
}
}
return $polylang_data;
}
@@ -384,37 +371,6 @@ class StarterSite extends Site {
return $logos;
}
private function getVideos() {
$post = Timber::get_post();
//error_log('✅ ID Página: ' . $post->ID);
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
if ($post && ( $post->ID === 9 || $post->ID === 392) ) {
global $wp_query;
$temp_query = $wp_query;
$wp_query = new \WP_Query([
'post_type' => 'videos',
'posts_per_page' => 20,
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'DESC',
'paged' => $paged,
]);
// Timber::get_posts() SIN PARÁMETROS usa la query global ($wp_query)
$posts = Timber::get_posts(); // Lee de la query global que acabamos de crear
$pagination = new \Timber\Pagination($wp_query->max_num_pages);
$wp_query = $temp_query; // Restaurar query original
return $posts;
}
return ['posts' => [], 'pagination' => null];
}
private function getPaginasAcerca() {
return Timber::get_posts([
'post_type' => 'acerca',
@@ -794,13 +750,18 @@ class StarterSite extends Site {
}
public function getVideosSlider() {
$post = Timber::get_post();
error_log('✅ getVideosSlider - ID Página: ' . $post->ID);
return [
'posts' => Timber::get_posts([
'post_type' => 'videos',
'posts_per_page' => -1,
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'DESC'
'order' => 'DESC',
'lang' => '' // Importante: vacío para obtener todos
]),
'pagination' => null
];