WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] wp_query in category.php page break navigation (5 posts)

  1. codedmind
    Member
    Posted 5 years ago #

    Hy there,

    I have a category page template, but i need to use the wp_query function. because i want to order the post by a custom field.

    The problem is with next_posts_link that never show up. I have this

    $limit = get_option('posts_per_page');
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $posts=query_posts($query_string . 'showposts=' . $limit . '&paged=' . $paged .'&orderby=numero_socio&order=asc');

    The nex link never show. If i put in the url &paged=2 for instace i go to the next page and the previous link show and work, but again the next post link don't came up beside i have almost 10 pages ini the category...

    Any ideias? Please

  2. jbbrwcky
    Member
    Posted 5 years ago #

    Does it work if you change 'query_posts' to 'new WP_query'?

  3. codedmind
    Member
    Posted 5 years ago #

    Can you please post an example?

  4. codedmind
    Member
    Posted 5 years ago #

    Ok now works

    $limit = get_option('posts_per_page');
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $my_query =new WP_query(($query_string . 'showposts=' . $limit . '&paged=' . $paged .'&orderby=numero_socio&order=asc');

    But with this i must change the loop to this
    <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>

    Solved

  5. zovanni
    Member
    Posted 4 years ago #

    There's an extra parenthesis at the third line
    here is the correct code

    $limit = get_option('posts_per_page');
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $my_query =new WP_query($query_string . 'showposts=' . $limit . '&paged=' . $paged .'&orderby=numero_socio&order=asc');

Topic Closed

This topic has been closed to new replies.

About this Topic