Community Forums › Forums › Archived Forums › Design Tips and Tricks › Right location for file to insert CSS?
Tagged: css, navigation, Outreach Pro, wp_enqueue_style
- This topic has 3 replies, 1 voice, and was last updated 9 years, 6 months ago by okieman.
-
AuthorPosts
-
May 24, 2015 at 2:36 pm #153505okiemanMember
After days of testing site only installed on my PC so far, I realize the best way to customize the way my primary nav menu displays is to insert a bit of CSS. (This is Outreach Pro on Genesis.) My customer wants it to look different on all internal pages. My recent code follows, but when it loads, it somehow causes the top half of the <head> section to disappear. Yeah that breaks the page.
In header.php (inside /themes/outreach-pro) there's this ...
<?php // Have also tried get_stylesheet_directory_uri() in the following wp_register_style( 'nav-all-nonsplash-pgs', get_template_directory_uri().'/nav-all-internal-pgs.css','all'); if ( ! is_front_page() ) { //* NOT viewing the home page wp_enqueue_style( 'nav-all-nonsplash-pgs' ); }
... then in nav-all-internal-pgs.css there's this ...
.nav-primary #menu-item-572 { display:none; } .nav-primary #menu-item-658 { display:none; }
May 24, 2015 at 7:48 pm #153514okiemanMemberPartial progress. The css file being loaded had to go in the Genesis directory instead of the Outreach Pro directory where everything else is going on.
The last remaining problem is getting this PHP "if" statement to tell the difference between the default first page in the site and everything else. I tried it with both || and && between the two names for such a page.
if ( ! is_front_page () && is_home() )
Using these two ampersands nothing at all happens on either the splash page. Using two pipes does load the style but the not (!) is somehow non-functional. The css loads everywhere including the splash where it's not needed.
May 24, 2015 at 8:17 pm #153516okiemanMemberFrom the codex:
You can only use conditional query tags after the posts_selection action hook in WordPress (the wp action hook is the first one through which you can use these conditionals). For themes, this means the conditional tag will never work properly if you are using it in the body of functions.php, i.e. outside of a function.
Not a happy camper.
May 26, 2015 at 6:39 pm #153737okiemanMemberTwo bits of news for anyone who may wander down this road:
1- Someone has proposed a simple CSS solution that I'm now using. By adding/removing the page-id selector, and by taking advantage of the fact that CSS is processed in order, with the most recent code having priority.
2- It's been suggested I can use a conditional tag inside functions.php via a WordPress hook. So that's my side project while the site functions happily via the CSS mod, proposed by "CrouchingBruin" ....nav-primary #menu-item-572, .nav-primary #menu-item-658, .nav-primary #menu-item-747 { display: none; } .page-id-2 .nav-primary #menu-item-572, .page-id-2 .nav-primary #menu-item-658, .page-id-2 .nav-primary #menu-item-747 { display: inline-block; } .page-id-2 .nav-primary #menu-item-834 { display: none; }
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.