Saltar al contenido Saltar a la barra lateral
Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 -
- - - - - - -

Zona horaria del soporte: Asia/Karachi (GMT+05:00)

Etiquetado: 

Este tema contiene 0 respuesta, tiene 1 voz.

Última actualización por francescof-8 hace 8 meses, 1 semana.

Asistido por: Waqas Bin Hasan.

Autor Publicaciones
Abril 10, 2025 a las 10:17 am #16917700

francescof-8

Background of the issue:
I am trying to show a list of 6 non-sticky posts in chronological order (from the newest) using a shortcode function. Here is my primary function: function fnztema_list($params = array()) { $configs = wp_parse_args($params, _getDefaults()); $queryArgs = _getQueryArgs($configs); $the_query = new WP_Query( $queryArgs ); $res = ''; if ( $the_query -> have_posts() ) { $classes = _returnStyleClasses($configs); $count = $the_query -> found_posts; $loop_counter = 1; $res .= ''; if ($configs['heading'] == 'true') { $res .= _returnListHeading($configs); } if ($configs['type'] === 'focus' && $count > 1) { $res .= ''; $res .= ''; } else { $res .= ''; } while ( $the_query->have_posts()) { $the_query -> the_post(); if (($configs['is_sticky'] === 'true' && $loop_counter 1) { $res .= ''; } $res .= $configs['is_sticky'] == 'true' ? get_option( 'sticky_posts' ) : '', 'post__not_in' => $configs['is_sticky'] == 'true' ? '' : get_option( 'sticky_posts' ), 'posts_per_page' => $configs['number'], 'order' => $configs['order'], 'orderby' => $configs['orderby'], ); if($configs['include'] !== null){ $arrId = explode(',', $configs['include']); $args['post__in'] = $arrId; } if($configs['exclude'] !== null){ $arrId = explode(',', $configs['exclude']); $args['post__not_in'] = $arrId; } if($configs['catsid'] !== null){ $idarr = explode(",", $configs['catsid']); $taxArr = array( array( 'taxonomy' => 'category', 'field' => 'term_id', 'terms' => $idarr, ) ); $args['tax_query'] = $taxArr; } if ($configs['type'] === 'notice') { $today = date('Ymd'); $args['meta_key'] = 'end_date'; $args['orderby'] = 'meta_value'; $args['order'] = 'ASC'; $args['meta_query'] = array( array( 'key' => 'end_date', 'value' => $today, 'compare' => '>=', 'type' => 'DATE' ) ); } return $args; } Here is my simple shortcode instance: [list number="6"] Link to a page where the issue can be seen: enlace oculto

Symptoms:
I expected to see only non-sticky posts for that language (ENG). Instead, I got a list starting with a post that is sticky in ITA (and not in ENG), another post that is sticky in ESP (and not in ENG), and then 6 non-sticky posts in chronological order.

Questions:
Why are sticky posts from other languages appearing in the list?
How can I ensure only non-sticky posts for the specified language are displayed?

El tema '[Cerrado] Wrong query with sticky post in ather languages' está cerrado a nuevas respuestas.