Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS [Solved] Showing Logo Problem

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #191371
    crawling
    Participant

    Hello,

    I am trying to make the logo that i uploaded for category news to appear on all articles posted in that category .
    Below you can see the logo for the category news
    http://unitednews.sr/category/news/

    Now this is a article posted in the category news but the logo does not show .
    http://unitednews.sr/news/vijf-rredenen-waarom-venture-capital-niet-werkt/

    In css i added this code for the logo to show on single articles that are part of that category.

    body.category-1 #logo a { background: url(http://unitednews.sr/wp-content/uploads/2014/11/logo.png) no-repeat;
    height: 26.5px;
    width: 150px;
    display: block;}

    body tag should make it work right ?

    #191373
    Senff
    Participant

    Sorry, but we can’t check it since the site is in Maintenance Mode.

    Having said that, the class “category-1” is only applied on pages that show posts in that category. By default, a single post in that category does not have that class in the body, o so you may have to add that functionality that a single post gets the class of every category it belongs to.

    #191376
    crawling
    Participant

    Forgot to disable maintenance mode , yes i did add this code in my functions.php
    `function add_category_body_classes( $classes ) {

    if ( is_single() ) {
        global $post;
        $cats = get_the_category($post->ID);
        foreach( $cats as $cat ) {
        $classes[] = 'category-' . $cat->slug;
        }
    }
    
    return $classes;
    

    }
    add_filter( ‘body_class’, ‘add_category_body_classes’ );`

    #191380
    Senff
    Participant

    That code adds a class with the category slug, not the category id.

    So, it’ll have category-news and not category-1. Make sure you target that in the CSS:

    body.category-news #logo a { 
        background: url(http://unitednews.sr/wp-content/uploads/2014/11/logo.png) no-repeat;
        height: 26.5px;
        width: 150px;
        display: block;
    }
    

    Also noticed that there is HTML code (social icons) in the HEAD of your document, not in the BODY.

    #191429
    crawling
    Participant

    Got It !
    Thank you for your help.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘CSS’ is closed to new topics and replies.