Update to Listings Pagination Issue

Published: Feb 02, 2013

A couple of Realty theme users have pointed out that the pagination doesn’t work once you’ve searched for a listing. This is now fixed and you can download a fresh copy of Realty which addresses this issue. Please go to the Realty page and reinstall the theme.

The Fix

For those of you who wants to add the code manually, open up search-listings.php and follow the instructions below:

Right on the top of the page, add session_start() *after the opening php tag.

Also compare the old code from the one below:

$list = array();
$item = array();
if($_POST){
	foreach($_POST as $key => $value){
		if($value != ''){
			$item['taxonomy'] = htmlspecialchars($key);
			$item['terms'] = htmlspecialchars($value);
			$item['field'] = 'slug';
			$list[] = $item;
		}
	}
	$_SESSION['realty-search'] = !empty($list) ? $list : array();
}
$search = !empty($_SESSION['realty-search']) ? $_SESSION['realty-search'] : array();
$cleanArray = array_merge(array('relation' => 'AND'), $search);

You see that I wrapped the foreach() loop, within a check for a $_POST. I also added the $list (which are the search terms) and plugged it into the final $cleanArray. This will save your search terms in session until the next time you click the submit button from the search form. Now test the previous and next links after submitting a search. The listings should now keep their state and should work properly.

For an explanation of how the search form works – go to this tutorial . Please leave comments below if you are having problems.

Did you know you can Write for us?

Check out our Guest Post Guidelines to see what it takes.

Submit an Article

38 thoughts on “Update to Listings Pagination Issue

    Robert-Jan Kempink says:

    can you please help me, i did just a fresh installation of this theme and put 1 test listing in but if i use the search bars i don`t get any results, also test a new installation of wordpress but also the same problem 🙁

    Robert-Jan Kempink says:

    can you please help me, i did just a fresh installation of this theme and put 1 test listing in but if i use the search bars i don`t get any results, also test a new installation of wordpress but also the same problem 🙁

    Robert-Jan Kempink says:

    i use wordpress 4.4 and realty 1.2

    Mitchel Debock says:

    I found the solution for me atleast after braking my head
    permalinks set to default…
    need to be year , month, name
    problem fixed for me

    Andrea Marchetti says:

    Hi, i have exactly the same code but the pagination make a 404 error, the permalink is correct but the page is 404, pleae helpme

    P says:

    Post your site here. I will check

    David Q. says:

    Hello, I’m using this theme but the search engine didn’t work in my installation. I downloaded the Realty.zip file last version on Sep, 17th, 2013 and installed it on my website but it didn’t work. I’m using wordpress 3.6.1 spanish version. Any suggestion?

    This is a very nice straight forward approach to a custom search engine with WordPress. Well done. But I have one question, I am using a similar approach, but with checkboxes instead of a select for my Areas. The name of my areas check boxes are area[].

    WordPress does not seem to like the field array when parsing it into the query var, especially when I select multiple areas. So my first page of results works fine with multiple areas selected, but pagination breaks after that.

    Any ideas on an approach for this?

    I was thinking of applying an Implode to my $_POST var and assigning it to a query_var. But that seems like a lot of extra work just to save the values for pagination.

    Cheers,
    E.

    save to a string and implode the values should be okay. i suggest to use wp_session to remember the values – which is more secure i am just now finding out. i have yet to do another update.

    Michael Soriano says:

    save to a string and implode the values should be okay. i suggest to use wp_session to remember the values – which is more secure i am just now finding out. i have yet to do another update.

    Andrea Marchetti says:

    I have the same problem pleae help! if you have a pay pal i can pay you..

    AlexD says:

    Hi. My code is exactly the same as above, but when I try to use the search form, it still throws out a “404 – page not found” error. Please help, much thanks in advance!

    make sure you set up the listing page : http://fearlessflyer.com/2012/08/manage-your-listings-with-realty-theme/
    in the section:
    Set up the Listing Search Results Page

    AlexD says:

    Got it, thanks! Another question; I’d like to replace the newer and older posts links with numbered pagination, is there a way to do that within Realty without using a plugin?

    AlexD says:

    Found a solution for the pagination issue, so you can disregard my last question. If anyone else has trouble with this, just download the WP-PageNavi plugin and replace the next and previous links with $the_query) ); ?>. All credit and thanks to abdulawal39.

    AlexD says:

    Found a solution for the pagination issue, so you can disregard my last question. If anyone else has trouble with this, just download the WP-PageNavi plugin and replace the next and previous links with $the_query) ); ?>. All credit and thanks to abdulawal39.

    AlexD says:

    Sorry about that, the code is: [?php wp_pagenavi( array( ‘query’ => $the_query) ); ?]

    B says:

    Hello, where exactly do I add unique text to every post? I see in single listing.php the following:

    Listing Details

    But how should I be able to add text just to the created post so it shows up underneath “listing details”?

    B says:

    Hello, where exactly do I add unique text to every post? I see in single listing.php the following:

    Listing Details

    But how should I be able to add text just to the created post so it shows up underneath “listing details”?

    B says:

    ok got it.

    David Q. says:

    Hello, I’m using this theme but the search engine didn’t work in my installation. I downloaded the Realty.zip file last version on Sep, 17th, 2013 and installed it on my website but it didn’t work. I’m using wordpress 3.6.1 spanish version. Any suggestion?

    David Q. says:

    Sorry! my mistake. The Search engine is working very well. I had an old installation and install the new one on old one. I removed the db (just one real state) and created it again. After I installed wordpress and theme again and this process worked well. Thanks!

    dee says:

    Hi, How do i add “for rent” and “for sale” category on the form? Please help, thanks much and more power on this theme.

    The Rag Factory says:

    The front page of the demo seems to have problems on iPhone5 under iOS6. Other pages are fine. The background and all content scales to about 75% of the available width, with just a few letters of the word ‘Neighborhood’ spilling off the right onto the neutrai underlying background. Picture attached.

    The Rag Factory says:

    The front page of the demo seems to have problems on iPhone5 under iOS6. Other pages are fine. The background and all content scales to about 75% of the available width, with just a few letters of the word ‘Neighborhood’ spilling off the right onto the neutrai underlying background. Picture attached.

    thank you. I’ll look into it.

    chalito says:

    Hi michael…I checked the php in search-listings.php same you but it is not working
    my site : http://www.cmemarketplace.com

    please help ..

    This worked for me

    next_posts_link(‘« Older Entries’, $the_query->max_num_pages)
    and
    previous_posts_link(‘Newer Entries »’)

    Guest says:

    This worked for me

    max_num_pages) ?>

    Daniel says:

    How do I remove the About the Realtor Widget?

    i believe it’s in the home page template.

    dzul says:

    Hi michael…thanks for awesome themes…really appreciate it! I’ve a problem…how to create a page in the menu that show/list all our listings?please help…

    just add a link to your search results page (ie: http://realty.fearlessflyer.com/listing-search-results/) – and it should return all results.

    Russ says:

    I checked the php and it is the same as yours but it is not working

    http://edit.sailfishproperties.com/ I’m just started putting in properties when i noticed it isn’t working. This is the 404 I’m getting with firebug when i try to search

    rocco says:

    Hi, i still have problem!
    I changed the code manually.
    Here is the website.. can you check what’s wrong pls?

    http://www.rentmyroom.it

    ty

    you dont have enough listings to paginate.

    Andy says:

    Hello,
    Today I visit your page and see that you resolved the problem.
    How’d you do?

Comments are closed.