query_post parameters are not retained starting from second page (3 posts)

  1. pegroeg
    Posted 5 years ago #


    The page that I am referring to can be found at:

    There are 4 posts there - 2 have location Braila and 2 have location Bucuresti. Location is a custom field for posts. There is 1 post per page.

    I have a drop down list in which I can filer the posts based on location.
    By default, there are 4 pages, a page per post.

    If I chose Braila for example, there will be 2 pages, because there are 2 post with Braila. The problem appears here, when I click second page - the second page here is actually the second from all the 4 pages before using the drop down list.

    Here is the code that I am using:
    $aLocalitati = $wpdb->get_col( $wpdb->prepare("SELECT DISTINCT (meta_value) FROM wp_postmeta WHERE meta_key='Localitate'"));
    //arguments of query posts - default for all localities
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $category = 'terenuri-tenis-camp';
    'category_name'=> $category,
    'posts_per_page'=> 15,

    if(isset($_POST['select_location'])) {
    $selected_location = $_POST['select_location'];
    if($selected_location != "all") {
    'category_name'=> $category,
    'posts_per_page'=> 15,
    'meta_key'=> 'Localitate',
    'meta_value'=> $selected_location,
    <td style="padding: 10px;">Filtreaza dupa locatie:</td>
    <td><form name="location_form" action="<? echo get_bloginfo(wpurl).'/'.$category;?>" method="post">
    <select class="select" name="select_location" onchange="this.form.submit();">
    <option value="all">Oricare</option>
    foreach ( $aLocalitati as $location ) {
    if (isset($selected_location) and $selected_location == $location) {
    echo '<option value="'.$location.'" selected="selected">'.$location.'</option>';
    } else {
    echo '<option value="'.$location.'">'.$location.'</option>';

    $temp_query = $wp_query;

    if (have_posts()) :
    while (have_posts()) : the_post(); ?> ............

    <?php endwhile; ?>
    <?php if(function_exists('wp_paginate')) {
    } ?>

  2. pegroeg
    Posted 5 years ago #

    The 'posts_per_page'=> 15 is actually 'posts_per_page'=> 1;

  3. Eric Martin
    Plugin Author

    Posted 5 years ago #

    WP-Paginate uses values set by WordPress. If the plugin is not working, it means there is something wrong with your query or set-up.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP-Paginate
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic