WordPress.org

Ready to get started?Download WordPress

Forums

Replacing Category with Featured Image (5 posts)

  1. CheeseRex
    Member
    Posted 1 year ago #

    http://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!

  2. Ayman
    Member
    Posted 1 year ago #

    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;
    }
  3. CheeseRex
    Member
    Posted 1 year ago #

    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.

  4. Ayman
    Member
    Posted 1 year ago #

    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;
    }
  5. Ayman
    Member
    Posted 1 year ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic