Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #25549

    Gday Kriesi

    I’d like to add the post category name to the post items as an additional class in the source code.

    I have identified what I think is the right place within postslider.php. (I did a test with a ‘plain’ class and it did output the term)

    So then I tried changing line 310 from:

    $output .= "<div class='slide-entry flex_column {$style} {$post_class} {$grid} {$extraClass} {$thumb_class}'>";


    $output .= "<div class='{$category} slide-entry flex_column {$style} {$post_class} {$grid} {$extraClass} {$thumb_class}'>";

    with no success.

    I also tried adding ' . $category->cat_name . ' in the same place but I broke the page.

    Does anyone know how I may be able to achieve this?




    In postslider.php replace

    $post_class = "post-entry post-entry-{$the_id} slide-entry-overview slide-loop-{$post_loop_count} slide-parity-{$parity} {$last}";


    $post_class = "post-entry post-entry-{$the_id} slide-entry-overview slide-loop-{$post_loop_count} slide-parity-{$parity} {$last}";
    $postcats = get_the_category($the_id);
    foreach($postcats as $postcat)
    $post_class .= ' '.$postcat.' ';


    Thanks for your help with this Dude. When I do the replacement I get this error:

    Catchable fatal error: Object of class stdClass could not be converted to string in /home/birdsnest/public_html/blog/wp-content/themes/enfold/config-templatebuilder/avia-shortcodes/postslider.php on line 253

    Do you have any ideas about what I may need to change?


    I had some help from a colleague, replace line 253 with either of the following:

    $post_class .= ‘ ‘.$postcat->cat_name.’ ‘; // if you want the category name, or

    $post_class .= ‘ ‘.$postcat->cat_ID.’ ‘; // if you want the category ID


    Hi itchybrain,

    Glad you were able to find the fix and thank you for posting the results :)



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

The topic ‘Dynamically Add the Category Name to Grid Layout Source Code’ is closed to new replies.