Search code examples
csswordpressthemeshide

Is there any css code to hide this features from site homepage


I am using the Discy Wordpress theme.

What css code could I use to hide the share button and author's name from the post loop only.

Here is a screenshot of what I would like to hide


Solution

  • I'd recommend inspecting the elements you want to hide in your browser and add display: none to the class/id on those elements.

    Ex. Say I want to hide the 'Your Answer' text here. enter image description here

    I would then add some CSS

    h2.space {
        display:none;
    }
    

    Edit:

    Based on your needs there are a couple options:

    Edit the templates used by Wordpress to exclude these elements on the necessary pages.

    or

    Insert some jQuery that will hide the elements on a specific page.

    $(document).ready(function() {
       if (window.location.href.indexOf("home") > -1) { // What the url contains on the page you don't want these elements to display
            $( "h2.space" ).addClass( "hidden" );
       }
    }
    

    Of course, this solution requires jQuery and a hidden CSS class defined, like:

    .hidden {
      display: none;
     }
    

    Some sort of class like that may already be defined in the Wordpress theme you're using.

    Fiddle for this solution: https://jsfiddle.net/p6af32td/