[wp-hackers] Strange shortcode / header issue with search

Casey Bisson casey.bisson at gmail.com
Tue Sep 25 03:19:42 UTC 2012


In addition to what Daniel suggests (and he's spot on), you might also look into what caching is going on. The pattern you describe where you get one result on initial page load and another result after a reload is common for caching errors where the result is not properly cached so that it can be output where it belongs. 

Definitely start with Daniel's suggestion, a that's probably the cause of problems in the initial page load, and fixing that might fix the different result you get in the next page load. 

--Casey

On Sep 24, 2012, at 5:55 PM, Daniel Bachhuber <wordpress at danielbachhuber.com> wrote:

> Can you make sure the shortcode is returning its content, not echoing? This common mistake can produce results like you're seeing if the_content is applied to a post before the loop
> 
> On Sep 24, 2012, at 17:49, Jeffrey Nolte <jnolte at getmoxied.net> wrote:
> 
>> I currently have a very strange issue happening with a site that we recently developed.  Basically what happens is when there is a fresh search on the site and the post that is returned for the search results has an image gallery (that we set up as shortcode using wp media library) the photo gallery is injected into the dom before the opening html tag and this is done using javascript.  As you can imagine this completely mangles the layout of the site.  Does anyone have any ideas on the issue or somehow that I can start debugging it?  I have listed step by step what happens below.
>> 
>> 1. Do a search for "television"
>> 2. I am returned a page with results for "television" with a photo gallery injected into the dom before the opening html tag via JS.
>> 3. I refresh the page and it is gone.
>> 
>> **Note: the photo gallery is a custom post type which is inserted into posts with a shortcode- there were many reasons for this approach as we needed to insert galleries into more than one post and replace a ton of flash galleries in existing content that was merged into new theme.
>> 
>> Some info about setup
>> WordPress 3.4.2
>> Relevenssi Plug-in for search
>> Running NGINX / w3 Total Cache and Varish with PHP-FPM
>> VPS Ubuntu 12.04 LTS


More information about the wp-hackers mailing list