- This topic has 8 replies, 2 voices, and was last updated 3 years, 6 months ago by
Tom.
-
AuthorPosts
-
March 5, 2019 at 10:05 am #829745
Whelan
Hi
I’ve created a child theme and use the GP Premium hooks.
I also use bootstrap 3.0 css
My site is getting quite css heavy and script heavy.
I now want to specify some print styles and think it’s best to put these in a separate css file that’s only used when required.I tried to follow this codex https://codex.wordpress.org/Styling_for_Print
It says to “insert this code to create a link in the head section of my header.php template file”
<link rel="stylesheet" type="text/css" media="print" href="<?php bloginfo('stylesheet_directory'); ?>/print.css" />
Is this the best way to do it? Or should I use the wp_head hook? I tried inserting the code in the wp_head text box, but I don’t think it worked am a little out of my depth when it comes to WP hooks and PHP.
GeneratePress 2.2.2GP Premium 1.7.8March 5, 2019 at 5:24 pm #830050Tom
Lead DeveloperLead DeveloperThe
wp_head
hook is definitely the way to go.That code assumes there’s a print.css file inside the root directory of your child theme.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMarch 5, 2019 at 11:46 pm #830210Whelan
Thanks for your reply. Yes, that’s what I’ve done but it’s not working.
I’ve uploaded print.css to the root directory of the child them.
I’ve inserted the code intowp_head
andexecute php
is checked.
It’s hosted with GoDadddy ‘managed wp’, so I used their ‘flush cache’ tool and cleared the cache on my browser – not working.
—-
To test my print.css, I edited header.php and added to the child theme. This method is working but I’d prefer to usewp_head
.
—-
Can you see anything I’m doing wrong?March 5, 2019 at 11:48 pm #830215Whelan
This is my print.css:
/* Print Styles */ @media print { body { background:white; color:black; margin:0; } #site-navigation, #sidebar {display:none; } #commentform,#respond { display:none; } #content, #comments { display:block; } #footer-widgets, #at-expanding-share-button { display:none; } h1, h2, h3, h4, h5, h6 { page-break-after:avoid; page-break-inside:avoid; } img { page-break-inside:avoid; page-break-after:avoid; } blockquote, table, pre { page-break-inside:avoid; } ul, ol, dl { page-break-before:avoid; } .d-print-none, .hidden-print { display:none; } }
March 6, 2019 at 10:02 am #830801Tom
Lead DeveloperLead DeveloperTry this:
<link rel="stylesheet" type="text/css" media="print" href="<?php bloginfo('stylesheet_directory'); ?>/print.css" />
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMarch 6, 2019 at 10:08 am #830803Whelan
No that doesn’t work. I assume I need to select
execute php
?March 6, 2019 at 10:12 am #830813Tom
Lead DeveloperLead DeveloperLooks like it’s working: http://prntscr.com/mu7af9
It’s loading correctly ๐
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentSeptember 9, 2019 at 10:27 am #1005046Whelan
Yes, working now. Thanks (sorry it took me so long to reply).
September 9, 2019 at 3:55 pm #1005241Tom
Lead DeveloperLead DeveloperNo problem ๐
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-development -
AuthorPosts
- You must be logged in to reply to this topic.