S
S
skdon2015-10-30 02:13:02
WordPress
skdon, 2015-10-30 02:13:02

The $paged Wordpress global variable is set to 0. Why?

I want to make a static page with navigation. CMS wordpress. A piece of code below.

$wp_query = new WP_Query(); $wp_query->query('showposts=3' . '&paged='.$paged);
        while ($wp_query->have_posts()) : $wp_query->the_post(); ?>

Can you please tell me why the $paged global variable can be empty? And when called
$pageNum=(get_query_var('paged')) ? get_query_var('paged') : 1;

don't get anything either?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
W
WP Panda, 2015-10-30
@skdon

$paged=(get_query_var('paged')) ? get_query_var('paged') : 1;
$wp_query = new WP_Query(array('posts_per_page'=>3,'paged'=>$paged));
if ( $wp_query ->have_posts() ) {
  while ( $wp_query ->have_posts() ) {
    $wp_query ->the_post();

For a static page
$paged = (get_query_var('page')) ? get_query_var('page') : 1;

A
Alexander Aksentiev, 2015-10-30
@Sanasol

it should become non-empty on the second page

S
skdon, 2015-10-30
@skdon

I understand it. That's just the point that /page/2/ and $paged is empty. On the first page, if displayed, it writes 0, and on the second it is empty.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question