1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to add css in to php wordpress files?

Discussion in 'Web Design' started by NikoNikic, Feb 1, 2017.

  1. NikoNikic

    NikoNikic Regular Member

    Joined:
    Jul 25, 2015
    Messages:
    236
    Likes Received:
    15
  2. Michael Saba

    Michael Saba Newbie

    Joined:
    Jan 30, 2017
    Messages:
    8
    Likes Received:
    2
    Gender:
    Male
    Check out this link which will help you to add CSS files in HTML page.

    Go to w3schools.com and search a topic CSS How to. That will help you do it.


    Thank you,
    Michael Saba
     
  3. TomasJay

    TomasJay Newbie

    Joined:
    Dec 22, 2016
    Messages:
    11
    Likes Received:
    0
    Gender:
    Male
    If you have applied your html tags correctly, you would simply have to link your css file at the top of the html code so that it would apply the styling.
     
  4. Conor

    Conor Elite Member

    Joined:
    Nov 7, 2012
    Messages:
    3,579
    Likes Received:
    5,965
    Gender:
    Male
    Location:
    South Africa
    Home Page:
    Code:
    <style>
    // Your CSS Here
    </style>
    
     
  5. blogzandstuff

    blogzandstuff Elite Member

    Joined:
    Jan 1, 2015
    Messages:
    6,422
    Likes Received:
    3,002
    Occupation:
    blog creator
    Location:
    UK
    you don't add CSS to the PHP, CSS is done in your CSS file. In your child theme put any changes in there, always use a child theme with WordPress, never edit or adapt core code. You will lose any changes you make when there is an update
     
  6. Adi11

    Adi11 Newbie

    Joined:
    Jan 25, 2017
    Messages:
    39
    Likes Received:
    3
    Gender:
    Male
    You can do any CSS coding with the help of Jetpack plugin which is free on WordPress
    use this plugin to edit or add any CSS code on WordPress.

    But you need an account on wordpress.org (which is free).
     
  7. blogzandstuff

    blogzandstuff Elite Member

    Joined:
    Jan 1, 2015
    Messages:
    6,422
    Likes Received:
    3,002
    Occupation:
    blog creator
    Location:
    UK
    Trouble with Jetpack is it wants to take over, it's annoying when the work can be done in a child theme so one less plugin
     
  8. Adi11

    Adi11 Newbie

    Joined:
    Jan 25, 2017
    Messages:
    39
    Likes Received:
    3
    Gender:
    Male
    You may be right, but I find this easy as compare to child theme

    Child theme method requires some experience and it's not a method for a newbie I guess.
     
  9. blogzandstuff

    blogzandstuff Elite Member

    Joined:
    Jan 1, 2015
    Messages:
    6,422
    Likes Received:
    3,002
    Occupation:
    blog creator
    Location:
    UK
    Yes you are quite right there, Child themes can be a bit daunting. I am so use to using them i forget at times that beginners need easier solutions.
     
    • Thanks Thanks x 1
  10. Adi11

    Adi11 Newbie

    Joined:
    Jan 25, 2017
    Messages:
    39
    Likes Received:
    3
    Gender:
    Male
    You are right my friend, and there are some update issues as well when using a child theme method.
     
  11. blogzandstuff

    blogzandstuff Elite Member

    Joined:
    Jan 1, 2015
    Messages:
    6,422
    Likes Received:
    3,002
    Occupation:
    blog creator
    Location:
    UK
    No update issues with a child theme, that's the point of it. If you use a child theme you don't have to update it when the theme is updated as Wordpress checks the child theme first and then moves onto the core files. anything inside of a child theme is never overwritten, that's why professionals like myself use them. Imagine if you have lots of clients, you'd be forever going back to the same sites updating, that why we use child themes
     
    • Thanks Thanks x 1
  12. Adi11

    Adi11 Newbie

    Joined:
    Jan 25, 2017
    Messages:
    39
    Likes Received:
    3
    Gender:
    Male

    Well I read somewhere about update issue, but I guess that's not the case
    and thank you for correcting me as I hardly use child themes for editing purpose.
     
  13. CPI marketeer

    CPI marketeer Registered Member

    Joined:
    Jan 28, 2017
    Messages:
    66
    Likes Received:
    9
    Gender:
    Male
  14. blogzandstuff

    blogzandstuff Elite Member

    Joined:
    Jan 1, 2015
    Messages:
    6,422
    Likes Received:
    3,002
    Occupation:
    blog creator
    Location:
    UK
    That's ok, WordPress.org advises to always use child themes, as it's a child of the main theme ( hence the name ) it's not the child theme that gets updated, it's always the core code of wordpress itself, udates never affect the child theme, that's why we use them. It saves time and hassle as you make changes once and never have to touch it again, no matter how many times a theme is updated
     
    • Thanks Thanks x 1
  15. blogzandstuff

    blogzandstuff Elite Member

    Joined:
    Jan 1, 2015
    Messages:
    6,422
    Likes Received:
    3,002
    Occupation:
    blog creator
    Location:
    UK
    Genius!!!! ;)
     
  16. NikoNikic

    NikoNikic Regular Member

    Joined:
    Jul 25, 2015
    Messages:
    236
    Likes Received:
    15
    I've done it with this tutorial (external style sheet). I've extracted HTML and CSS with SnappySnippet, img here (and element I shuld see) and just added them to my files. When I open my index file with crome I see only HTML.
    What am I doing wrong?
     
  17. blogzandstuff

    blogzandstuff Elite Member

    Joined:
    Jan 1, 2015
    Messages:
    6,422
    Likes Received:
    3,002
    Occupation:
    blog creator
    Location:
    UK
  18. NikoNikic

    NikoNikic Regular Member

    Joined:
    Jul 25, 2015
    Messages:
    236
    Likes Received:
    15
  19. ibmjango

    ibmjango Regular Member

    Joined:
    Jul 3, 2010
    Messages:
    297
    Likes Received:
    77
    In your functions file you suppose to enqueue style here is how to do it.

    Function add_theme_style()
    {
    wp_enqueue_style('style',get_template_directory_uri.'/css/style.css);
    }

    add_action('wp_enqueue_scripts','add_theme_style');

    One more thing dont copy above code as i just wrote this to explain how enqueue works

    so go in google and look for enqueue in wordpress.

    hopr it will help you.
     
  20. NikoNikic

    NikoNikic Regular Member

    Joined:
    Jul 25, 2015
    Messages:
    236
    Likes Received:
    15
    Alright this is what I have now. Endings of index.php and style.css
    As you can see I've added css to style.css (9MB), added link rel in index.php
    And still I can only see basic HTML
    Only suspicious thing I've found was js in index.php
    What did I do wrong?
    Trying to solve this problem a whole month or months...:(