WordPress.org

Ready to get started?Download WordPress

Forums

Posts By Tag
[resolved] display post category classes in outputted code (5 posts)

  1. cfabrice
    Member
    Posted 2 years ago #

    How can I modify the code so that I get my posts categories classes in the html code, I need it in order to style differently my posts titles according to their category ?
    Thank you

    http://wordpress.org/extend/plugins/posts-by-tag/

  2. Sudar
    Member
    Plugin Author

    Posted 2 years ago #

    You have to modify the get_posts_by_tag() function to output the category as well.

  3. cfabrice
    Member
    Posted 2 years ago #

    Thank you !
    I've tried to change line 663 from $output .= '<a href="' . get_permalink($post) . '">' . $post->post_title . '</a>';
    to this $output .= '<a class="' . implode(' ',get_post_class()). '" href="' . get_permalink($post) . '">' . $post->post_title . '</a>';
    And I get my classes in the code, but it's always the same ones from the same post...
    any idea why ?

  4. Sudar
    Member
    Plugin Author

    Posted 2 years ago #

    Change this

    get_permalink($post) . '">' . $post->post_title . '</a>';
    to this $output .= '<a class="' . implode(' ',get_post_class()). '" href="' . get_permalink($post) . '">' . $post->post_title . '</a>';

    to

    get_permalink($post) . '">' . $post->post_title . '</a>';
    to this $output .= '<a class="' . implode(' ',get_post_class('', $post->ID)). '" href="' . get_permalink($post) . '">' . $post->post_title . '</a>';
  5. cfabrice
    Member
    Posted 2 years ago #

    Thank very much you it works perfectly !
    Great plugin, very handy !

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic