I want to include a different inline <style>
tag that contains a php include in my wordpress header.php file based on wether it’s my blog or it’s a page.
in simple words i want my blog to have this in the <head>
<style type="text/css">
<?php include '../css/1.css.php';?>
</style>
and i want my pages to have this other one in the <head>
<style type="text/css">
<?php include '../css/2.css.php';?>
</style>
I’ve found this snippet and the distinction between blog and pages works, the problem is the include line
<?php
if(is_page()){
echo 'Foo';
include ('../css/above-the-fold-contact.css.php');
echo 'Example: one';
}
else{
echo 'Foo something else';
include ('../css/above-the-fold-blog.css.php');
echo 'Example: two';
}
?>
it does inject the right file in the right page, but I need to wrap the include around <style>
tags, not doing so cause the content of the file to be injected as plain text. how do I do that? what’s the syntax? any help is really appreciated, thanks so much!
EDIT : Just a quick mention – if your CSS is not generated dynamically, then there are better ways of doing this ( like
wp_enqueue_style
, for example )