Files
andaira/actualidad.php
2025-07-29 09:01:20 +00:00

83 lines
2.0 KiB
PHP

<?php
global $params;
//~ global $paged;
//~ if (!isset($paged) || !$paged){ $paged = 1; }
$context = Timber::get_context();
$templates = array('actualidad.twig');
$mainargs = array(
'post_type' => 'post',
'post_status' => 'publish',
'numberposts' => 1,
'orderby' => array(
'date' => 'DESC'
),
'tax_query' => array(
array(
'taxonomy' => 'category',
'field' => 'term_id',
//~ 'terms' => array (29,32,64,30,36,38,40,33,37),
'terms' => array (29,141,30,139,37,140,138,32,36,38,40,33),
'operator' => 'NOT IN',
//'terms' => array (1), //Noticias
//'terms' => array (45), //Portada
)
),
);
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
'offset' => 1,
'numberposts' => 50,
'orderby' => array(
'date' => 'DESC'
),
'tax_query' => array(
array(
'taxonomy' => 'category',
'field' => 'term_id',
//~ 'terms' => array (29,32,64,30,36,38,40,33,37),
'terms' => array (29,141,30,139,37,140,138,32,36,38,40,33),
'operator' => 'NOT IN',
)
),
);
// Configuración con offset dinamico
//~ $args = array(
//~ 'post_type' => 'post',
//~ 'post_status' => 'publish',
//~ 'posts_per_page' => 3,
//~ 'paged' => $paged,
//~ 'orderby' => array(
//~ 'date' => 'DESC'
//~ ),
//~ );
//~ codex.wordpress.org/Making_Custom_Queries_using_Offset_and_Pagination
//~ add_action('pre_get_posts', 'actualidad_query_offset', 1 );
//~ function actualidad_query_offset(&$args) {
//~ $offset = 1;
//~ $posts_per_page = 3;
//~ if ( $args->is_paged ) {
//~ $page_offset = $offset + ( ($args->query_vars['paged']-1) * $posts_per_page );
//~ $args->set('offset', $page_offset );
//~ }
//~ else {
//~ $args->set('offset',$offset);
//~ }
//~ }
$context['posts'] = new Timber\PostQuery($args);
$context['mainpost'] = new Timber\PostQuery($mainargs);
$context['section_title'] = 'actualidad';
//~ $context['pagination'] = Timber::get_pagination();
Timber::render( $templates, $context );