WordPress.org

Ready to get started?Download WordPress

Forums

WP Custom Fields Search
Pagination removing space in query (5 posts)

  1. alexfish
    Member
    Posted 3 years ago #

    If i search using the plugin on my site using a query with a space in, everything works great until i hit page 2 of the pagination, the query string is then removing the +, eg for london zoo:

    http://www.reallykidfriendly.com/?search-class=DB_CustomSearch_Widget-db_customsearch_widget&widget_number=2&cs-all-0=london+zoo&cs--1=&cs-all-2=&search=Search

    page 2 is:

    http://www.reallykidfriendly.com/page/2/?search-class=DB_CustomSearch_Widget-db_customsearch_widget&widget_number=2&cs-all-0=londonzoo&cs--1&cs-all-2&search=Search

    which is then searching for londonzoo instead of my desired query,

    thanks for any help!

  2. ashworth102680
    Member
    Posted 3 years ago #

    I'm wondering the same thing. We have a URL structure like this...

    http://mydomain.com/some-category/?subject=Some+Subject

    I'm trying to get pagination properly working. I urlencode() the space and get the +, but it doesn't matter if I use a space or a + ...Wordpress always tries to do this...

    http://mydomain.com/some-category/page/2/?subject=SomeSubject

    ...instead of this...

    http://mydomain.com/some-category/page/2/?subject=Some+Subject

    WordPress is removing the space/+ for some reason. We haven't figured out why just yet. Any help is greatly appreciated.

  3. Erwin Smeman
    Member
    Posted 3 years ago #

    The problem is caused by the canonical redirect checked on using a theme. If you place
    remove_action('template_redirect','redirect_canonical');
    in the functions.php file belonging to your template, the problem is fixed.

    If you want more information, see
    this related issue.

  4. lerizzle
    Member
    Posted 3 years ago #

    Is there another fix. Cause remove_action('template_redirect','redirect_canonical'); just breaks everything.

  5. toastdesign
    Member
    Posted 2 years ago #

    <?php
    global $wp_query, $wp_rewrite;
    $wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : $current = 1;
    
    $pagination = array(
    	'base' => @add_query_arg('paged','%#%'),
    	'format' => '',
    	'total' => $wp_query->max_num_pages,
    	'current' => $current,
    	'show_all' => true,
    	'type' => 'plain'
    	);
    
    if( $wp_rewrite->using_permalinks() )
    	$pagination['base'] = get_bloginfo('url') . '/page/%#%/';
    
    $cq = $_GET['s'];
    	$sq = str_replace(" ", "+", $cq);
    
    if( !empty($wp_query->query_vars['s']) )
    	$pagination['add_args'] = array( 's' => $sq);
    
    echo paginate_links( $pagination );
    ?>

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic