• https://ednewsri.org/

    Here is the ideal

    My biggest desires are to

    1) replace the green block category with a featured image (The category title with the little stripes that match the header), but not have the featured image in the post.

    2) move the blog title up so it’s next to the category block / image.

    I’ve figured it all out so far, but hit a wall here. Any ideas? Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Ayman

    (@aymanalzarrad)

    1) replace the green block category with a featured image (The category title with the little stripes that match the header), but not have the featured image in the post.

    Not really clear what you mean.

    2) move the blog title up so it’s next to the category block / image.

    Create a child theme and apply to it this css:

    .entry-cats{
    float:left;
    }

    Thread Starter CheeseRex

    (@cheeserex)

    Thanks Ayman.

    1) I guess I mean “category icons,” such that when I assign a post to a category, instead of displaying the category name (in text) at the top of the post, it will display the associated category’s image instead.

    2) Worked perfectly. I didn’t try it because I thought I already had, haha.

    Ayman

    (@aymanalzarrad)

    You can replace the category title as text with an image:

    1- Add this function to your child theme funtions.php.

    This function will replace the title of the category you specify with the image you specify.

    Don’t forget to replace “uncategorized” with the category you want.

    function category_icon($title, $id) {
        if (in_category('uncategorized', $id)) {
        $title = '<img class="category_icon" src="*YOUR IMAGE URL HERE*" alt="" /> ' . $title;
        }
        return $title;
    }
    add_filter('the_title', 'category_icon');

    2- You can do more now in css targeting the img class with something like this:

    .category_icon{
          background:#000;
    }
    Ayman

    (@aymanalzarrad)

    @cheeserex, any feedback or update on the above suggestion?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Replacing Category with Featured Image’ is closed to new replies.