0
私のショートコードではどのようにページ番号を付けようとしていますが、すべてのページがうまく表示されていて関連するページをクリックするとそのページのURLにもなります。常に同じであり、私のポートフォリオの投稿は常に同じです....ここに私の全体のコードは、この問題を考え出すのに助けてください。get_query_varは私のページの構造を理解していません
$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 = '<div class="section-title">';
$output .= '<h3>'.$element_title.'</h3>';
$output .= '<small>'.$element_caption.'</small>';
$output .= '</div>';
}
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 .= '<div class="element-item ' . $tax . ' ' . $post_cols . '" data-category="transition">';
if ($thumbnail_position != 'below_title') {
if ($pretty_photo != 'no') {
$output .= '<a href="' . $post_image = wp_get_attachment_url(get_post_thumbnail_id($post->ID)) . '" rel="prettyPhoto[gallery1]"><img src="' . $post_image = wp_get_attachment_url(get_post_thumbnail_id($post->ID)) . '"></a>';
} else {
$output .= '<a href="' . $post->guid . '"><img src="' . $post_image = wp_get_attachment_url(get_post_thumbnail_id($post->ID)) . '"></a>';
}
}
if ($show_post_title != 'no') {
$output .= '<h3><a href="' . get_the_permalink() . '">' . get_the_title() . '</a></h3>';
}
if ($show_description != 'no') {
$output .= '<p>' . $content = substr(get_the_content(), 0, $num_characters) . '</p>';
}
if ($thumbnail_position == 'below_title') {
if ($pretty_photo != 'no') {
$output .= '<a href="' . $post_image = wp_get_attachment_url(get_post_thumbnail_id($post->ID)) . '" rel="prettyPhoto[gallery1]"><img src="' . $post_image = wp_get_attachment_url(get_post_thumbnail_id($post->ID)) . '"></a>';
} else {
$output .= '<a href="' . get_the_permalink() . '"><img src="' . $post_image = wp_get_attachment_url(get_post_thumbnail_id($post->ID)) . '"></a>';
}
}
if ($read_more != '') {
$read_more = $read_more;
} else {
$read_more = 'Read More';
}
if (($show_post_title != 'no') && ($show_description != 'no')) {
$output .= '<a href="' . get_the_permalink() . '">' . $read_more . '</a>';
}
$output .= '</div>';
}
$output .= '</div>';
//$output .= paginate_links($args);
if($show_pagination != 'no') {
$big = 999999999;
$output .= '<div class="portfolio-pagination">' . 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 .= '</div>';
}
wp_reset_query();
wp_reset_postdata();
return $output;
}
}}
はい、問題はあなたの間違ったコード、二重のクエリの使用である今:(
あなたのコードはすべて上手く見えます。再?はいの場合は、問題を見つけるのが簡単になるようにコード全体を提供できますか? –
はい他のコードがあります。質問を編集していて、そのコードも提供しています... – laraib
コードを更新しました、新しいコードは前のコードの最上位にあります....親切に私をガイドしてください...してください – laraib