Skip to main content
edited body
Source Link
Roman
  • 4.5k
  • 2
  • 23
  • 26

The pagination works only, if the paged attribute in the the global $wp_query variable is set. You could store your query manually in this global or just use query_posts() instead of new WP_Query().

<?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $the_query = query_posts(
        array(
            'post_type'=>'article',
            'posts_per_page'=>2,
            'orderby'=>'date',
            'paged'=>$paged
        )
    );
    // ...
?>

The function query_posts() will unset an existing $wp_query global, runs a new WP_Query() and stores the result again in the global $wp_query varibalevariable.

The pagination works only, if the paged attribute in the the global $wp_query variable is set. You could store your query manually in this global or just use query_posts() instead of new WP_Query().

<?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $the_query = query_posts(
        array(
            'post_type'=>'article',
            'posts_per_page'=>2,
            'orderby'=>'date',
            'paged'=>$paged
        )
    );
    // ...
?>

The function query_posts() will unset an existing $wp_query global, runs a new WP_Query() and stores the result again in the global $wp_query varibale.

The pagination works only, if the paged attribute in the the global $wp_query variable is set. You could store your query manually in this global or just use query_posts() instead of new WP_Query().

<?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $the_query = query_posts(
        array(
            'post_type'=>'article',
            'posts_per_page'=>2,
            'orderby'=>'date',
            'paged'=>$paged
        )
    );
    // ...
?>

The function query_posts() will unset an existing $wp_query global, runs a new WP_Query() and stores the result again in the global $wp_query variable.

Source Link
Roman
  • 4.5k
  • 2
  • 23
  • 26

The pagination works only, if the paged attribute in the the global $wp_query variable is set. You could store your query manually in this global or just use query_posts() instead of new WP_Query().

<?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $the_query = query_posts(
        array(
            'post_type'=>'article',
            'posts_per_page'=>2,
            'orderby'=>'date',
            'paged'=>$paged
        )
    );
    // ...
?>

The function query_posts() will unset an existing $wp_query global, runs a new WP_Query() and stores the result again in the global $wp_query varibale.