This topic contains 3 replies, has 2 voices, and was last updated by
- April 15, 2020 at 10:12 pm #26753Participant
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,
JoeApril 16, 2020 at 12:48 pm #26767Keymaster
Well, it hardly depends on how it exactly looks like in your case, but, you need to replace this
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,
If you like my products, don't forget to rate them on codecanyon :)
April 16, 2020 at 1:13 pm #26770Participant
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 #26771
You must be logged in to reply to this topic.