Jump to content

Wordpress: Problem with pagination and spaces in URL


pealo86

Recommended Posts

I've only just noticed this problem, and I'm certain it didn't exist a few months ago! Perhaps it had something to do with a WP update or plugin.

 

Basically, I have a page which lists a load of excerpts depending on what the value of $_GET['category'] is.

 

Here is the query I am using:

<?php query_posts('post_type=company&meta_key=Category&meta_value=' . $_GET['category'] . '&orderby=title&order=ASC&paged=' . $paged); ?>

 

The problem occurs when $_GET['category'] consists of multiple words, such as "Web Design". However, I am not using spaces in my hyperlinks, rather they are like so:

<li><a href="<?php bloginfo('url'); ?>/directory/?category=Web+Design">Web Design</a></li>

 

And this works fine when on the first page of results, however when I go to page 2, the URL in the address bar changes like so:

 

Notice how the '+' has disappeared between 'Web' and 'Design'.

 

I cannot understand why this is happening however, because I am using the posts_nav_link() function like so:

<?php posts_nav_link(' ', '<li><img src="' . get_bloginfo('template_url') . '/image/paginate-prev.gif" alt="Previous Page" /></li>', '<li><img src="' . get_bloginfo('template_url') . '/image/paginate-next.gif" alt="Next Page" /></li>'); ?>

 

This gives me the correct link on the frontend. So if I hover over the 'Next' button, it is trying to take me to:

 

Which is correct, but for some reason WP is just stripping that '+' character out of the URL after the link has been clicked.

 

Does anyone have any ideas why it might be doing that? Maybe I should just try a fresh install and reconfiguring everything? Although that is only a last resort for me.

Link to comment
Share on other sites

I remember hitting something along those lines a while back, but it wasn't the same context and I figured out an alternative.

 

I'm not much of an expert, but as an alternative, what if you used a wordpress function to get the category, such as get_categories().

All the other category functions are here.  Or a meta value function.  As for the source of the problem, I really don't know enough.  :shrug:  Sorry I can't be of more help.

Best of luck!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.