Hey varma, thanks for the kind words.
I think the problem you are getting is not to do with the plugin at all.
With the query you put above
http://www.domain.com/?post_types=product
The only thing the plugin will do is modify your query to restrict it by the post type. It will not have any affect on display.
You need to find out the template that is being used to display the results and modify it accordingly to use the excerpt.
Thanks
Thread Starter
varma
(@evildon)
Really thanks for quickly reverting back.
Actually I have created two custom post types and added this function that allow all custom post types to show in search results ( this i found on another blog) –
function any_ptype_on_cat($request) {
if ( isset($request['category_name']) )
$request['post_type'] = 'any';
return $request;
}
add_filter('request', 'any_ptype_on_cat');
No edits on any temple files. I also have created respective archive pages (archive-custom post type slug) for the custom post types.
But when ever the search query runs like this – http://www.domain.com/?post_types=product the whole list of posts from the custom post type is shown (along with full content).
But When manually going to http://www.domain.com/product/ then the correct result with excerpt is showing.
Can i can partially which page shows up when querying the /?post_types=product and how can i change it?
**One more thing i’m building the template from scratch from a blank template.
Regards
Hey varma
I think it is loading a different template to the ones you have created…
This
http://www.domain.com/?post_types=product
should load the same template as
http://www.domain.com/
So I guess you need to find out which template file this is, and you could do a switch on $_GET['post_types']
in that template to either load the rest of the template or do something different as you want.
Let me know if that makes sense?
Thread Starter
varma
(@evildon)
Hi
I think the query
http://www.domain.com/?post_types=product
is using up the single.php file and its displaying all posts under that post type.
But while using the custom post URl slug
http://www.domain.com/product
its correctly loading the archive like template.
Why both using different templates instead of one? Any solution to it.
Hi varma
Unfortunately the plugin doesn’t overwrite the way WordPress handles your templates…
The post types filter of the plugin is exactly that – a filter to restrict the post types that are displayed from search results. As your not searching for anything using this URL
http://www.domain.com/?post_types=product
It will filter what ever content you see on the homepage – unfortunately there is no built in integration for post type archives or custom templates & url structure.
Actually… I just had a thought…!!
What happens when you do:
http://www.domain.com/?post_types=product&s=
ie, a blank search?
There is a hidden option to always add a s=
to the URL which may help load a search template – you need to use add_search_param
like this:
[searchandfilter fields="search,category,post_tag" add_search_param="1"]
Let me know!
Thread Starter
varma
(@evildon)
The search parameter didn’t work out, when blank searching its simply showing all post under post types with full content :(.
And even if i put any search term still the same above result.
I think the default WordPress custom post url url is http://www.domain.com/?post_types=product ( if not rewritten) and it will show a template with full content 🙁
Any way to change the query from ?post_types=product to product with url cleaning?
If possible i think it will work as http://www.domain.com/product is working as excepted.
Thread Starter
varma
(@evildon)
Ok, I have somewhat got a work around for it.
By default custom post type query http://www.domain.com/?post_types=product
displays the templates index.php file.
So i changed it’s Post content to Post excerpt. Thus now only display a excerpt of the content with a read more link.
Also changed the Front page displays settings to a static page, to avoid any issues.
Hope this work around will solve some issues.
Testing around for any bugs..
Glad you managed to get a workaround!
Just to let you know WP uses
http://www.domain.com/?post_type=product
and this plugin uses
http://www.domain.com/?post_types=product
Notice the “s” – post_types
I implemented this so that you can filter using multiple post types which WP doesn’t inherently support!
Thanks for the info 🙂