Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Result Templating
This topic contains 3 replies, has 2 voices, and was last updated by Ernest Marcinko 3 years, 1 month ago.
- AuthorPosts
- April 15, 2020 at 10:12 pm #26753
Hi,
Firstly, I love this product – it is working like a dream for me. I am trying to make some tweaks in-terms of customising the search results. I have copied all of the files from the relevant area and placed them into a folder called ‘asp’. My issue is my lack of knowledge in-terms of advanced coding. What I want to do is ammend the ‘item’ div so that the post’s category is output into the class for example, post category is ‘Alert’ and this would output as <div class=’item alert etc etc’. I am stuck trying to get past ‘$r->content_type == ‘terms”. I have no idea what I’m meant to do from here or what the final code should look like for me to achieve what I need to achieve.
Thanks in advance,
Joe
April 16, 2020 at 12:48 pm #26767Hi,
Well, it hardly depends on how it exactly looks like in your case, but, you need to replace this
<div class='item'>
with something like:
<div class="item <?php echo $r->content_type == 'pagepost' ? ' ' . implode(' ', wp_get_post_categories($r->id, array('fields'=>'slug'))) : ''; ?>">
This may not work out of the box, but should be very close to a proper solution.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
April 16, 2020 at 1:13 pm #26770Awesome!
I just tweaked it a little and the end result returns the category ID – which is fine enough for me to set my style according to the post’s category. For the benefit of everyone else who may require the same for their project, the code I used was:
<?php echo $r->content_type == 'pagepost' ? '' . implode('', wp_get_post_categories($r->id, array( 'name' => $cat->name, 'slug' => $cat->slug ))) : ''; ?>
Thanks again Ernest!
April 16, 2020 at 1:14 pm #26771You cannot access this content. Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
- AuthorPosts
You must be logged in to reply to this topic.