Linked Stylesheet in WordPress - wordpress

I am trying to build a second .css file for my company's website.
Currently, we are using a responsive theme, so most of our content displays correctly on desktop and mobile browsers. However, recently the boss is requesting custom code that is unresponsive. In order to keep the site looking good, I want to apply a secondary stylesheet that contains formatting for mobile devices. It would be like this for any html page:
<link rel="stylesheet" href="http://domain.tld/mobile.css" type="text/css" media="handheld" />
I cannot figure out how to get this into a wordpress child theme correctly. Can anyone offer suggestions?
Thank you in advance.

Look for the header.php file in your child theme directory, or under "Appearance"->"Editor" in the main menu of the your Wordpress adminpanel. You can paste the link to your new stylesheet there.
Also consider moving the styles to your theme's directory and replacing the domain in your href with <?php echo get_stylesheet_directory_uri(); ?> (example from wordpress codex).

Related

Wordpress Jetpack Sharing Icons Broken

I'm using Jetpack social sharing icons. If I enable them on Front Page, Archives, etc. they work almost everywhere (Search Results, Posts, etc.).
However, they break on Post Excerpts such as when listed in a post-loop on the Blog page. Each icon shows a square where the icon should be.
Any idea what's causing this?
See behavior here: [redacted]
Click a post to see icons as they should be.
It looks like the CSS for the genericons is not being loaded on the /blog page, but it is being loaded for an article. It looks like this in the HTML:
<link rel="stylesheet" id="genericons-css" href="http://newman.tamucc.edu/wp-content/plugins/jetpack/_inc/genericons/genericons/genericons.css?ver=3.1" type="text/css" media="all">
It's a little bit of a hack because I'm not sure how exactly Jetpack is loading it's styles, but you should be able to get the icons to load on every page by adding this line to the top of your functions.php file:
wp_enqueue_style( 'genericons', get_template_directory_uri() . '../../plugins/jetpack/_inc/genericons/genericons/genericons.css', array(), '3.1' );

CSS of Blank Theme Does NOT Show My Edits - Why?

On Wordpress.org, I activated a BLANK theme by Chris Coyier.
I edit index.php and my changes are showing up on my website. Fantastic.
I edit the existing style.css file but none of my edits are showing up. Ugh.
I delete style.css and the website still works. Why?
I repeat these steps with a different blank theme. Same issues.
Questions
Why am I unable to edit style.css of ANY blank theme? I am confused because I am able to edit style.css of Twentyfourteen theme.
If I delete style.css from the blank theme, the website still works and still shows the same CSS styling. How is this possible?
For blank themes, the stylesheet is called in header.php as
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" />
But for Twentyfourteen theme, I don't see any call for a stylesheet.
Why do regular themes not have a call for a stylesheet in header.php? Is this why I cannot edit style.css of blank themes?
Most likely your browser is caching the CSS?
What happens when you use your browsers dev tools to check the CSS source.does that show your edits?
When you say "delete the CSS" do you get a missing resource error on the browser console?
If it does not, try force reloading your page.

How to get magento header in wordpress

I am having word press installed in side a sub directory of magento like
---Magento
----wp
--Blog (This is word press directory)
In word press we have header.php in theme folder.There I am trying to access the magento header block.
I am able to get this following way(Below code is written in head section of header.php of wordpress)
Mage::getLayout()->createBlock('page/html_head')->toHtml();
When I echo this I am able to get the magento header.But the css and js of magento application are not rendered as well the word press application is halting after rendering the content of magento. i.e nothing comes after header.
Please suggest me idea how can I get the css and js of magento application and the wordpress content properly?
The dirty way is to link Magento JS and CSS in your header.php file. like
<script type="text/javascript" src="<?php getSkinUrl('jsfolder/js.js') ?>"></script>
<link rel="stylesheet" type="text/css" href="<?php getSkinUrl('cssfolder/style.css') ?>">
There's actually a tweak in page.xml file but I wonder how, or why not to play it yourself?

Wordpress alternate css file to working

Hi everyone for the help in advance: Im trying to get a 2nd header added to a custom temp page and in that alternate header all an alternate css file different from style.css.
I called the custom header from the cat template page like this
<?php get_header('header_state'); ?>
It works fine and places the header on the page and I called the css file in this custom header like this:
<link rel="stylesheet" type="text/css" href="<?php bloginfo('template_url'); ?>//localhost:8888/cnb_press/wp-content/themes/cnb-zip1/state_style.css" media="screen" />
but my page is still accessing the index.php style.css for some reason. I am on a MAMP and not live.
Any ideas why I am not getting this right?
If your page is still showing the incorrect CSS link tag, you aren't loading the new header template you created. WordPress wouldn't redirect an absolutely URLed CSS file referenced in the header.
Look at the WordPress template hierarchy to make sure your page is loading the template you think it is:
http://codex.wordpress.org/Template_Hierarchy

Wordpress Child-Theme CSS not Reflecting on Site

I've semi-successfully created a wordpress child-theme. By successfully I mean:
I managed to create a child-theme directory in my themes folder, next
to my main theme
I created a style.css file in the child-theme dir
I saw the style show up on my Wordpress back-end and managed to activate it
I added templates (header.php, sidebar.php,...) to the directory
I made changes to the above templates and saw the changes on my site
However, there is one huge problem:
Whatever CSS I try to add to the style.css file, it's not affecting the site
I know the "information header" must be ok since I was able to see/activate the child-theme. But I really can't figure out what is wrong. I tried removing the #import rule, which according to the Wordpress codex should remove all styles from my site - nothing happened.
I'm using the Panorama theme and created "panorama-technology" as a child. Below you can see the code I have in the style.css file inside the child-theme: "panorama-technology":
/*
Theme Name: panorama-technology
Template: panorama
*/
#import url("../panorama/style.css");
#search{
margin: 15px 15px 0 0;
}
WouterB, I had the same problem with my child theme loading in the backend, and child php pages overriding the parent theme php pages, but NO child CSS changes loading to override the parent styles.
So,although with different coding, it turns out my parent theme was written in such a way that the header was also looking for the stylesheet in the template directory, so your solution was spot on in concept.
Thus, by changing the call in the header from :
<link rel="stylesheet" type="text/css"
href="<?php echo get_template_directory_uri();?>/style.css" />
to:
<link rel="stylesheet" type="text/css"
href="<?php echo get_stylesheet_directory_uri();?>/style.css" />
--did the trick like magic. At least as far as I can tell so far.
You get major credit in my book!
First I'd try an absolute path to be sure that the path isn't the problem. If that does not solve the issue. Place the #import at the very top of the css file or directly after thelast "*/". I think white space is probably the culprit here.
Do not use import.
Add time after css uri for refreshing everytime.
In your function.php
function child_style() {
wp_enqueue_style( 'parent-child', get_stylesheet_uri().'?'.time());
}
add_action( 'wp_enqueue_scripts', 'child_style', 20 );
Watch out from caching :
wp cache plug-ins
server side cache (APC etc.)
local browser cache

Resources