Jump to content
AngelosTzelepis

Search Results Don't Use Sections from Search Template

Recommended Posts

AngelosTzelepis

My search results page seems to be igonring the sections that I've included in the Search template (the default search template in the drag and drop section). I can't figure out where it's pulling the sections from. To test, I removed everything from the default search template and carried out another search, but the search results are still displayed on the page along with the sidebar etc. I would've expected an empty content area.

I've attached a screenshot of my drag and drop area. The search results still show even though I've removed everything from it. Probably worth mentioning that I don't have a custom search template in my child theme (i.e. a search.php file).

Any help would be appreciated,

John

post-34877-0-72519700-1349629939_thumb.j

Share this post


Link to post
Share on other sites
Simon

Add content area, then add sections to the content area.

Share this post


Link to post
Share on other sites
AngelosTzelepis

Yes, I did that originally but it wasn't displaying the correct sections on the front end. So i've moved everything from the content area as a test. What happens is that the search results still show, despite there being nothing in the content area! How can this be possible? I've cleared cache etc, so it's not that.

It's almost ike the wrong template is being used for my search results.

Share this post


Link to post
Share on other sites
Rob

First, in your Page Template for Search you must have Content present. Then, in Content Area, the Search template must have Posts Info and PostLoop present in order to display results.

It's possible because you may have PostLoop in the Content Area.


Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites
AngelosTzelepis

Thanks for getting back to me Rob. There's nothing in the content area either, yet it still pulls in results. Is there any way to use a template other than the default search template to display the search results? It seems like that's what is happening - there is a different template hooked up the the search results.

Share this post


Link to post
Share on other sites
Rob

It's possible Wordpress is delivering the results within the generic or default PageLines template. Since I cannot see your site to try it, there's no way for me to tell.


Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites
AngelosTzelepis

I've carried out a template by template test and discovered that the search results are being pulled into a template called 'Tribe Events'. I am using a plugin called 'The Events Calendar' by modern tribe, which uses that template to display event listings. I suspect it's because there are events in the search results that it's defaulting to that template. That leaves a problem because I don't want my search results and events listing to have the same template.

Is there any way to create a custom search template in Pagelines? One that can pull in sections?

I'll also contact the plugin authors to see if they know of a solution.

Share this post


Link to post
Share on other sites
Danny

Well we already provide a search template, if the plugin is also using this template and causing issue. Therefore, the best course of action would be to contact the plugin author and ask them to investigate, as I added several sections to my search page template and these sections were visible and working as intended.


Please search our forums, before posting!

Share this post


Link to post
Share on other sites
miramax

I've seen the same thing happening when search results include custom post types.  Somehow, the template for the Search Results Page is being switched to the template for the custom post type...so the sections defined for the Search template in drag/drop don't display...instead, you get the sections from the custom post type template.  

 

Question is, how could this possibly happen, and how to fix?

Share this post


Link to post
Share on other sites
James B

Hi, just to check are you using Platform Pro or Pagelines Framework at the moment?

 

Would you be able to show us an example of this working so we can check it with a developer.

 

So if have a custom post type come up in the search results, the template for the page the search results display on, switch from what you've set up for the search template to that of the custom post type template?


Kindly search the forum and read the documentation before posting. It will help you resolve many issues.

For CSS help be sure to check out W3Schools first and be sure to download FireBug for FireFox for troubleshooting.

James B

Share this post


Link to post
Share on other sites
miramax

MHC, I figured out how to resolve the issue...

 

The problem is in the Pagelines template class...it's incorrectly assigning the template for the search results page when custom post types are include in search results.  To be fair, this may be the fault of a plugin that is overriding the filters that Pagelines tries to apply, but it's pretty easy to fix if you're comfortable modifying PHP code.  It's only one line.

 

Here's what I did:

 

1. Open /wp-content/themes/pagelines/includes/class.template.php

2. Look for this code (around line 60 in my case)

if( $template_type != false ) {
    $this->template_type = $template_type;
} else {
    if(is_admin()) {
        $this->template_type = $this->admin_page_type_breaker();
    } else {
        $this->template_type = $this->page_type_breaker();
    }
}

 

 

3. Update as follows

if( $template_type != false ) {
    $this->template_type = $template_type;
} else {
    if(is_admin()) {
        $this->template_type = $this->admin_page_type_breaker();
    } else {
        $this->template_type = $this->page_type_breaker();
        //ADD THIS LINE
        if (is_search()) {
             $this->template_type = 'search';
        }
    }
}

 

You're basically forcing the template type to be 'search' if the is_search() is true.  This is definitely a workaround, but it solved the problem for me and took 5 minutes to do.

Share this post


Link to post
Share on other sites
Simon

You should never have to edit files. Unless you want to edit every time you update.

 

if you follow page_type_breaker() you will see there is a filter at the bottom: 

 

return apply_filters('pagelines_page_type', $type, $post);

 

You should use this to override. 

Share this post


Link to post
Share on other sites
AngelosTzelepis

This issue has been resolved. The issue only occurred in a local development copy of the site and could not be reproduced on the production site. 

Share this post


Link to post
Share on other sites
thomlaw

You should never have to edit files. Unless you want to edit every time you update.

 

if you follow page_type_breaker() you will see there is a filter at the bottom: 

 

return apply_filters('pagelines_page_type', $type, $post);

 

You should use this to override. 

 

Can you shed a little light on how to use the filters for this.  I'd like to achieve the same results but definitely don't want to this to be lost or impact updates.

 

@miramax:  cool find thanks

 

thanks much

 

-T

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×