WordPress.org

Ready to get started?Download WordPress

Forums

WP-PageNavi
Custom query & form submit - part 2 (1 post)

  1. rereradu
    Member
    Posted 2 years ago #

    I stumbled on the same problem as reported in osterman's post.

    I am using a form to create a custom query that displays posts from a custom post type archive matching a certain custom field (Eg: For "custom-post-type" show only posts that have the "custom-field" value selected from the form). I know, it's called filtering :P

    In ostman's post the solution was to use the "get" method instead of the "post" one, but noone's giving more details :(

    Here's my situation:

    My custom post type archive looks like this:

    www.example.com/custom-post-type-archive

    (note that I use the "post name" permalink setting)

    Upon form submission, the new url is this:

    www.example.com/custom-post-type-archive?key=value

    The custom query is set to show only posts with value of key custom field:

    $value = $_GET['value'];
    $paged = get_query_var('page');
    $args = array(
    		'post_type' => 'custom-post-type',
    		'meta_key' => 'key',
    		'meta_value' => $value,
    		'paged' => $paged,
    		'posts_per_page' => 10
    );
    $my_query = new WP_Query($args);

    After the loop I have:

    wp_pagenavi(array('query' => $my_query));
    wp_reset_postdata();

    The query works, I get the right results. But I have problems getting pagination to work. When I go to the next page, I get this url:

    www.example.com/custom-post-type-archive/page/2?key=value

    but pagination still shows like I'm on the first page and the results are the same.

    If I manually enter
    www.example.com/custom-post-type-archive?key=value&page=2
    I get the right results(from page 2), but the all navigation links are the same as the url.

    Please help (hints, resources, anything).
    Thx,
    Radu

    http://wordpress.org/extend/plugins/wp-pagenavi/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic