How to load a separate IE8 style sheet in wordpress - php

Due to not understanding the #import query for responsive behaviour IE8 is incorrectly displaying some of my wordpress website - http://dev1.markdavies.eu . To solve this I'd like to try having a separate style sheet for IE8/7/& 6 and have found the following code
<link rel="stylesheet" type="text/css" media="all" href="style.css"/>
<!--[if lt IE 9]>
<link rel="stylesheet" type="text/css" media="all" href="style-ie.css"/>
<![endif]-->
However I don't know which php file I should put it in. Or even if this is the best way to go about. Please could anyone advise.
I am using a child theme and am reasonably well conversed with the file structure and css, HTML and php code.
Thanks

Add the appropriate conditional comment to your theme’s header.php file right after the call to the theme’s default stylesheet.
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
<!--[if IE 7]>
<link rel="stylesheet" href="<?php bloginfo('template_directory'); ?>/ie7.css" media="screen" type="text/css" />
<![endif]-->
Then upload your new IE-specific stylesheet (ie7.css in the example above) to your theme folder.

For child theme, use:
<!--[if lt IE 9]>
<link rel="stylesheet" type="text/css" href=" <?php echo get_stylesheet_directory_uri(); ?>/ie.css" />
<![endif]-->

Thank you for your help everyone. Although it's not a child theme, the header.php uses the following form to call the style sheet;
<title><?php wp_title(); ?></title>
<link rel="stylesheet" href="<?php echo get_stylesheet_uri(); ?>" type="text/css" media="all" />
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
<?php wp_head(); ?>
So the last answer by vel did the trick. I inserted the conditional statement as follows;
<link rel="stylesheet" href="<?php echo get_stylesheet_uri(); ?>" type="text/css" media="all" />
<!--[if lt IE 9]>
<link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri(); ?>/style-ie.css" type="text/css" media="all"/>
<![endif]-->
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
<?php wp_head(); ?>
Out of interest, does it matter if it goes before or after the 'ping back' line of code? It seems to work for me either way.

Related

Change default style based on title

I am trying to change the default style based on title of the page.I found that as the easiest way to accomplish needs.
I load the default styling option in header.php file:
<link rel="stylesheet" data-them="" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="all" />
I suppose <?php bloginfo('stylesheet_url'); ?> loads style.css which is on same path as header.php
I commented out this the line <link rel="stylesheet" data-them="" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="all" /> and tried to check title with php, based on that condition I wanted to load different style.css file.
<?php
$title = get_the_title();
if($title === "Title1"){
?><link rel="stylesheet" data-them="" href="style.css" type="text/css" media="all" /><?php
}
elseif($title === "Title2"){
?><link rel="stylesheet" data-them="" href="style2.css" type="text/css" media="all" /><?php
}
else{
?><link rel="stylesheet" data-them="" href="style3.css" type="text/css" media="all" /><?php
}
?>
This code does not work for me and not sure why.. Styling is messed up
Please find below style in your theme. Mostly enqueue in functions.php file.
EX:
wp_enqueue_style( 'twentynineteen-style', get_stylesheet_uri(), array(),
wp_get_theme()->get( 'Version' ) );
Please add below line after your theme's default style.
(get_stylesheet_uri())
wp_dequeue_style('twentynineteen-style');
After that check it your issue.
Please dequeue default style using below function.
wp_dequeue_style('default-style');

CSS isn't used on php project in ubuntu 12.04

i'm trying to run a php project i created using windows in ubuntu 12.04LTS. For that reason i installed php5 apache2 and open_jdk_7 in my ubuntu system. The next step was to put the project (the file index.php, the directory CSS and other files and directories) inside var/www/webserver directory. Then i opened firefox and wrote myip/weserver/index.php . It indeed loaded the page but it wasn't using the css. By the way i am new in ubuntu so keep it simple if possible :/ . Any help will be really appreciated.
This is the starting part of the code tha i used on the windows version in index.php
<?php
define("SUBFOLDER","");
//has to be changed to DOCUMENT ROOT
define("ROOT","C:\webdev\apache\htdocs");
?>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="<?php echo SUBFOLDER."/"; ?>css/myCSSfile.css" rel="stylesheet" type="text/css">
<link rel="shortcut icon" href="<?php echo SUBFOLDER."/"; ?>images/dit.ico">
<link rel="stylesheet" href="<?php echo SUBFOLDER."/"; ?>css/search.css">
<link rel="stylesheet" href="<?php echo SUBFOLDER."/"; ?>css/button.css">
<link rel="stylesheet" href="<?php echo SUBFOLDER."/"; ?>css/button2.css">
<script type="text/javascript" src="<?php echo SUBFOLDER."/"; ?>js/resolutionfinder.js"></script>
<script type="text/javascript" src="<?php echo SUBFOLDER."/"; ?>js/changeInputValue.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="<?php echo SUBFOLDER."/"; ?>js/ajaxcalls.js"></script>
And this is how i changed the second define to use it on linux. maybe i give the root path wrong?
<?php
define("SUBFOLDER","/webserver");
//has to be changed to DOCUMENT ROOT
define("ROOT","/var/www/webserver");
?>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="<?php echo SUBFOLDER."/"; ?>css/myCSSfile.css" rel="stylesheet" type="text/css">
<link rel="shortcut icon" href="<?php echo SUBFOLDER."/"; ?>images/dit.ico">
<link rel="stylesheet" href="<?php echo SUBFOLDER."/"; ?>css/search.css">
<link rel="stylesheet" href="<?php echo SUBFOLDER."/"; ?>css/button.css">
<link rel="stylesheet" href="<?php echo SUBFOLDER."/"; ?>css/button2.css">
<script type="text/javascript" src="<?php echo SUBFOLDER."/"; ?>js/resolutionfinder.js"></script>
<script type="text/javascript" src="<?php echo SUBFOLDER."/"; ?>js/changeInputValue.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="<?php echo SUBFOLDER."/"; ?>js/ajaxcalls.js"></script>
Your OS has nothing to do with your CSS. Just check the path you are loading the CSS from, its most likely wrong.

Bootstrap3 Yii widget include error

I have configured Yii bootstrap3 extension BsHtml and bootstrap.widgets.BsPanel are working fine but when I use bootstrap.widgets.BsGridView or BsNavbar I am getting following error:
include(BsWidget.php): failed to open stream: No such file or directory
on F:\wamp\www\yii\framework\YiiBase.php(427)
put
Yii::import('bootstrap.widgets.BsWidget');
before class definition, to look for it, whenever needed
You can insert
Yii::setPathOfAlias('bootstrap.widgets.BsWidget', dirname(__FILE__).'/../extensions/bootstrap/behaviors/BsWidget');
in file protected/config/main.php before returning array.
first you should open the main.php in protected/config/main.php
find this cod in the main.php
'components'=>array(
and then add the below code in the array
'bootstrap'=>array(
'class'=>'bootstrap.components.Bootstrap',
),
for example
'components'=>array(
'bootstrap'=>array(
'class'=>'bootstrap.components.Bootstrap',
),
after that you should go to the protexted/views/layouts/main.php
and find this html
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/screen.css" media="screen, projection" />
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/print.css" media="print" />
<!--[if lt IE 8]>
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/ie.css" media="screen, projection" />
and then replac it with
<?php
echo yii::app()->bootstrap->register();
?>

joomla 1.5 Custom mobile framework not loading css

Hi Guys I have been tasked with moving a custom framework from joomla 1.5 to 3.0 I have gotten the framework to load the homepage perfectly however when I go to other pages the css wont load here is the code:
PHP:
<link rel="stylesheet" href="<?php echo $this->baseurl(); ? >templates/system/css/system.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $this->baseurl(); ?>templates/system/css/general.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $this->templateurl(); ?>/css/addons.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $this->templateurl(); ?>/css/layout.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $this->templateurl(); ?>/css/template.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $this->templateurl(); ?>/css/typo.css" type="text/css" />
HTML Output:
<link rel="stylesheet" href="http://flyvail/index.php/templates/system/css/system.css" type="text/css" />
<link rel="stylesheet" href="http://flyvail/index.php/templates/system/css/general.css" type="text/css" />
<link rel="stylesheet" href="http://flyvail/index.php/templates/FlyVail2/css/addons.css" type="text/css" />
<link rel="stylesheet" href="http://flyvail/index.php/templates/FlyVail2/css/layout.css" type="text/css" />
<link rel="stylesheet" href="http://flyvail/index.php/templates/FlyVail2/css/template.css" type="text/css" />
<link rel="stylesheet" href="http://flyvail/index.php/templates/FlyVail2/css/typo.css" type="text/css" />
<!-- CSS for handheld devices -->
<link rel="stylesheet" href="http://flyvail/index.php/templates/FlyVail2/css/handheld/layout.css" type="text/css" />
<link rel="stylesheet" href="http://flyvail/index.php/templates/FlyVail2/css/handheld/template.css" type="text/css" />
<!-- CSS for handheld devices -->
<link rel="stylesheet" href="<?php echo $this->templateurl(); ?>/css/handheld/layout.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $this->templateurl(); ?>/css/handheld/template.css" type="text/css" />
<!-- //CSS for handheld devices -->
I am not sure why it isn't loading right
Assuming this is in your template's index.php file, then try:
$doc = JFactory::getDocument();
$doc->addStyleSheet($this->baseurl.'/templates/'.$this->template . '/css/NAMEOFSTYLESHEET.css', $type = 'text/css', $media = 'screen,projection');
to add your style sheets instead.
My guess is that $this->baseurl() does not work with the () as it is a parameter, not a function. As such, your link is shown without the baseurl is generated by a relative link which also takes into account the base href that joomla sets. This means when you are not in the root of the site, it the link is wrong.
(Your code would probably work if you just removed all the ()s, but the addStyleSheet method is better practise)
If that doesn't work, can you take a look to see if the URL generated is different on your homepage where you say it works and the sub-page where you say it does not, and add this additional info to your question.

How to not display the full URL in the source

Using the Codeigniter framework I have noticed that when someone visits my site and right-clicks -> view source the entire URL of my file locations and links are displayed.
Currently it is displayed as
<link href="http://www.mysite.com/Content/css/ayoba.main.css" rel="stylesheet" type="text/css" />
I would like it to display like
<link href="/Content/css/ayoba.main.css" rel="stylesheet" type="text/css" />
You can try with base_url() like
<link href="<?php echo base_url();?>Content/css/ayoba.main.css" rel="stylesheet" type="text/css" />
or
<link href="<?php echo base_url('Content/css/ayoba.main.css');?>" rel="stylesheet" type="text/css" />
Or
<link href="/Content/css/ayoba.main.css" rel="stylesheet" type="text/css" />

Categories