All secondary loops on search page are broken!
-
I am using WordPress 4.3.1. Today I tried to add search functionality to my webpage (https://ganzinotti.com/aisb/). I created a searchform.php and a search.php. The search functionality works.
The only problem is that my ‘secondary’ loops are broken on my page displaying the search results. All my ‘secondary’ loops are initiated with “new WP_Query()”. I feel there is nothing wrong with my code, because on all other pages these additional loops are rendered correctly. Only on the search page there seems to be something wrong.
If you visit https://ganzinotti.com/aisb/ and scroll down to the footer you can see how it should be rendered. If you do a search for a keyword that has no results, nothing is rendered: https://ganzinotti.com/aisb/?s=abcd. If you search for a keyword with multiple hits it only renders the actual posts with hits: https://ganzinotti.com/aisb/?s=ethics.
I did find multiple people on the web with the same problem, but I didn’t find any solutions yet. It tried resetting the main loop and secondary loops in all possible combinations with “wp_reset_postdata();” and “wp_reset_query();”, but this didn’t help. According to my observations the global wp_query in the search page is stripped and reduced to only those posts that are a hit. Is there a way to change this and keep the wp_query with all posts, so I can run my secondary loops and maybe specify a custom “new WP_Query()” with the search string as argument…
Any help is more than welcome.
- The topic ‘All secondary loops on search page are broken!’ is closed to new replies.