Pages

Thursday, January 19, 2017

Wordpress using wrong template after AJAX loading

A tricky problem with my AJAX-search function. WordPress decided to use front-page.php for loading extra AJAX-content. The problem was that this styled the content in a different way than I needed. After identifying the root of the problem (which takes time!), I looked around for a neat solution. What I came up with was overriding the template hierarchy in case the request URL contains a “?” (which means we are searching). This is not a universal solution but it works for me. Add the following to your functions.php function ccb_template_override($template) { if( strpos($_SERVER['REQUEST_URI'],"?")!==false ) { return locate_template('search.php'); } return $template; } add_filter('template_include', 'ccb_template_override'); For a better solution that applies to all AJAX-loaded...

Wednesday, January 18, 2017

#TechCelebs

Chuck XORris, JK SIMmons, Alec Baldwindows, Bob DylLAN, George Cloney, Matt Damonitor, Prinstagram, Brad Pinterest TechCelebs silly — Kamiel Choi (@kamiel79) January 18, 2017 ...
Page 1 of 1412345Next

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Lady Gaga, Salman Khan