Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #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}'>";

    to:

    $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?

    cheers

    Darryl

    #127352

    In postslider.php replace

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

    with

    $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.' ';
    }

    #127353

    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?

    #127354

    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

    #127355

    Hi itchybrain,

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

    Regards,

    Devin

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.