Anonymous
Get_query_var не понимает структуру моих страниц
Сообщение
Anonymous » 10 окт 2024, 03:18
Я пытаюсь понять, как разбивка на страницы в моем коротком коде, все страницы отображаются нормально, и нажатие на соответствующую страницу также приводит к URL-адресу этой страницы, но данные страницы никогда не меняются на этой странице, они всегда остаются неизменными, и мое портфолио сообщения всегда одни и те же.... вот весь мой код, пожалуйста, помогите мне разобраться в этой проблеме.
Код: Выделить всё
$args = array(
'post_type' => 'portfolio',
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'DESC',
'posts_per_page' => $num_posts,
);
$push_args = array_slice($args, 0, 2, true) + $stack + $stack_cat_all + array_slice($args, 2, count($args) - 1, true) ;
query_posts($push_args);
if($show_title == 'yes'){
$output = '';
$output .= ''.$element_title.'';
$output .= ''.$element_caption.'';
$output .= '';
}
global $paged;
if ( get_query_var('paged') ) {
$paged = get_query_var('paged');
} else if ( get_query_var('page') ) {
$paged = get_query_var('page');
} else {$paged = 1;}
$args = array (
'post_type' => 'portfolio',
'posts_per_page' => $num_posts,
'post_status' => 'publish',
'paged' => $paged
);
$gallery_posts = new WP_Query($args);
if ( !empty($gallery_posts) ) {
if ($gallery_posts->have_posts()) {
while ($gallery_posts->have_posts()) {
$gallery_posts->the_post();
$terms = get_the_terms($post->ID, 'portfolio_category');
$links = array();
if (is_array($terms) || is_object($terms)) {
foreach ($terms as $term) {
$links[] = $term->name;
}
}
$links = str_replace(' ', '-', $links);
$tax = join(" ", $links);
$output .= '';
if ($thumbnail_position != 'below_title') {
if ($pretty_photo != 'no') {
$output .= '';
} else {
$output .= '';
}
}
if ($show_post_title != 'no') {
$output .= '' . get_the_title() . '';
}
if ($show_description != 'no') {
$output .= '
' . $content = substr(get_the_content(), 0, $num_characters) . '
';
}
if ($thumbnail_position == 'below_title') {
if ($pretty_photo != 'no') {
$output .= '';
} else {
$output .= '';
}
}
if ($read_more != '') {
$read_more = $read_more;
} else {
$read_more = 'Read More';
}
if (($show_post_title != 'no') && ($show_description != 'no')) {
$output .= '' . $read_more . '';
}
$output .= '';
}
$output .= '';
//$output .= paginate_links( $args );
if($show_pagination != 'no') {
$big = 999999999;
$output .= '' . paginate_links(array(
'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
'format' => '?paged=%#%',
'current' => max(1, get_query_var('paged')),
'total' => $gallery_posts->max_num_pages
));
$output .= '';
}
wp_reset_query();
wp_reset_postdata();
return $output;
}
}}
Это действительно убивает меня, потому что я уже потратил 3 часа впустую
Подробнее здесь:
https://stackoverflow.com/questions/378 ... -structure
1728519502
Anonymous
Я пытаюсь понять, как разбивка на страницы в моем коротком коде, все страницы отображаются нормально, и нажатие на соответствующую страницу также приводит к URL-адресу этой страницы, но данные страницы никогда не меняются на этой странице, они всегда остаются неизменными, и мое портфолио сообщения всегда одни и те же.... вот весь мой код, пожалуйста, помогите мне разобраться в этой проблеме. [code]$args = array( 'post_type' => 'portfolio', 'post_status' => 'publish', 'orderby' => 'date', 'order' => 'DESC', 'posts_per_page' => $num_posts, ); $push_args = array_slice($args, 0, 2, true) + $stack + $stack_cat_all + array_slice($args, 2, count($args) - 1, true) ; query_posts($push_args); if($show_title == 'yes'){ $output = ''; $output .= ''.$element_title.''; $output .= ''.$element_caption.''; $output .= ''; } global $paged; if ( get_query_var('paged') ) { $paged = get_query_var('paged'); } else if ( get_query_var('page') ) { $paged = get_query_var('page'); } else {$paged = 1;} $args = array ( 'post_type' => 'portfolio', 'posts_per_page' => $num_posts, 'post_status' => 'publish', 'paged' => $paged ); $gallery_posts = new WP_Query($args); if ( !empty($gallery_posts) ) { if ($gallery_posts->have_posts()) { while ($gallery_posts->have_posts()) { $gallery_posts->the_post(); $terms = get_the_terms($post->ID, 'portfolio_category'); $links = array(); if (is_array($terms) || is_object($terms)) { foreach ($terms as $term) { $links[] = $term->name; } } $links = str_replace(' ', '-', $links); $tax = join(" ", $links); $output .= ''; if ($thumbnail_position != 'below_title') { if ($pretty_photo != 'no') { $output .= ''; } else { $output .= ''; } } if ($show_post_title != 'no') { $output .= '' . get_the_title() . ''; } if ($show_description != 'no') { $output .= ' ' . $content = substr(get_the_content(), 0, $num_characters) . ' '; } if ($thumbnail_position == 'below_title') { if ($pretty_photo != 'no') { $output .= ''; } else { $output .= ''; } } if ($read_more != '') { $read_more = $read_more; } else { $read_more = 'Read More'; } if (($show_post_title != 'no') && ($show_description != 'no')) { $output .= '' . $read_more . ''; } $output .= ''; } $output .= ''; //$output .= paginate_links( $args ); if($show_pagination != 'no') { $big = 999999999; $output .= '' . paginate_links(array( 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), 'format' => '?paged=%#%', 'current' => max(1, get_query_var('paged')), 'total' => $gallery_posts->max_num_pages )); $output .= ''; } wp_reset_query(); wp_reset_postdata(); return $output; } }} [/code] Это действительно убивает меня, потому что я уже потратил 3 часа впустую :( Подробнее здесь: [url]https://stackoverflow.com/questions/37874791/get-query-var-not-understanding-my-pages-structure[/url]