WordPress.org

Ready to get started?Download WordPress

Forums

Flounder
Question: Easy way of changing colors per author? (2 posts)

  1. noxHand
    Member
    Posted 5 months ago #

    Hello,

    I am really liking the theme, and would like to use it on a personal blog where we are two people sharing the posts - we'd like to post at the same time on the same blog, but then have the posts come up in two different colors. Rather than having the very cool option of colors for the different post types, we'd like to have all posts in the same two colors, depending on the author.

    Is there a specific part of the code I should be looking up on, or is this a major rewrite?

    I ask the question simply so as to not have to spend many hours investigating (I am very low level in my CSS and such) to see whether it is indeed easily possible.

    Thanks for the awesome theme, and worry not if this is an intricate question that you do not feel up for responding to - I will have to do my best at reading up on the code instead :-)

    Cheers.

  2. salsaturation
    Member
    Posted 5 months ago #

    Do you have a Child_themes... If not create one and add the following to the functions.php file you will create as the theme uses

    post_class()

    //add an author class to post_class() by filter//
    function post_author_id_class($classes) {
    	    global $post;
    	    $classes[] = 'author-'.get_the_author_meta('user_nicename');
    	    return $classes;
    	}
    add_filter('post_class', 'post_author_id_class');

    This will then give you something like

    <article id="post-1178" class="post-1178 post type-post status-publish format-standard hentry category-featured author-noxhand">

    Notice the author-noxand which you can then target via css

Reply

You must log in to post.

About this Theme

About this Topic

Tags

No tags yet.