Result Templating

This topic contains 3 replies, has 2 voices, and was last updated by

 
Keymaster
1 year, 9 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #26753

    Participant

    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

    #26767

    Hi,

    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 :)


    #26770

    Participant

    Awesome!

    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!

    #26771
    You cannot access this content. Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.