Search code examples
phpcsswordpressif-statementstylesheet

If statement to call custom stylesheet


I am looking for a way to use an If statement to call a certain custom style something like

if ( is_page('page-id') ) {
    "line to call stylesheet2.css";
    }

Any ideas?


Solution

  • This should work for you:

    if(is_page('page-id')){
        echo '<link rel="stylesheet" type="text/css" href="my.css">';
    }else {
        echo '<link rel="stylesheet" type="text/css" href="another.css">';
    }