How to link a custom stylesheet to a page template?
-
Hi,
If anyone could help me with this I’d be really grateful.
I know that this is a question that’s been asked very frequently, however I’ve spent two days looking at other people’s posts trying to work out how to use my functions folder to link a custom stylesheet to a page template I’m working on.So far, the code I’ve found that looks the most likely to work is this one –
if( is_page_template( 'work.php' ) ) { wp_register_style("work-style", get_template_directory_uri() . "/css/page-template.css", '', '1.0.0'); wp_enqueue_style('page-template'); }
The page template I’m trying to create is called “work”, as I’ve tried to add to the code, however something I’m doing isn’t right, as it either uses the main stylesheet or it has no effect whatsoever, leaving me with a blank page between my header and footer.
You can see the code for my page template php below. (I’m very new to wordpress and coding in general, so if I’ve made any stupid errors, please let me know). I’ve developed the theme I’m using from scratch.
<?php /* Template Name:work */ ?> <link href="style.css" rel="stylesheet" type="text/css"> <link href="<?php bloginfo('stylesheet_url'); ?>" rel="stylesheet" type="text/css"> <body> <?php get_header(); ?> <div class="content" id= "workcontent"> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <div <?php post_class(); ?> id="post-<?php the_ID(); ?>"> <div class="entry"> <?php the_content(__('Read the rest of this entry »', 'kubrick')); ?> </div> </div> <?php endwhile; ?> <?php endif; ?> <div id="wrapper"> <a href="/landscapes"><div class="albums" id= "album1"></div></a> <a href="/seascapes"><div class="albums" id= "album2"></div></a> <a href="/macro"><div class="albums" id= "album3"></div></a> <a href="/cities"><div class="albums" id= "album4"></div></a> <a href="/long-exposure"><div class="albums" id= "album5"></div></a> <a href="/miscellaneous"><div class="albums" id= "album6"></div></a> </div> </div> </body> <?php get_footer(); ?>
- The topic ‘How to link a custom stylesheet to a page template?’ is closed to new replies.