• Follow us on Twitter
  • Join our Facebook Group
  • Join me on Google Plus
  • Add me on Linkedin
  • RSS
Welcome to Ontwerps close

  • Home
  • Over
  • Diensten
  • Portfolio
  • Blog
  • Contact

Blog

WordPress – Add CSS to a Single Post

0 Comments/ in Blog, CSS, Wordpress-CMS / by ontwerps
juli 7, 2010 Add the following immediately before the call to wp_head:
/*If the post has the 'css' custom field, load a stylesheet
	 *The stylesheet to load is based on the value of the 'css' field
	 */
	if ( get_post_meta($post->ID, 'css', true) ) {
		$style = get_post_meta($post->ID, 'css', true);
		$stylepath = get_bloginfo('template_url') . '/css/' . $style . '.css';
		echo "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"$stylepath\" />\n";
	}
For example, if you want to use a stylesheet called custom.css on your post, you’ll have to create a folder in your theme directory called css and put your stylesheet there (for me the path would be www.domainname.com/wp-content/themes/yourtheme/css). Then add a Custom Field to your post named css with the value custom.

No related posts.

← Photoshop problem with resizing text box
WordPress – Add Javascript to a Single Post →
Comments

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Geef een reactie Reactie annuleren

Je e-mailadres wordt niet gepubliceerd. Verplichte velden zijn gemarkeerd met *

*

*

De volgende HTML tags en attributen zijn toegestaan: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Categorieën

Tags

blackberry borders branding centos chrome cms color CSS css3 cycling debug font glyphs gradients hover HTML-HTML5 image import invoice iphone joomla jquery linux magento osx pattern photoshop scroll sql table Template textures twitter vcard Wordpress-CMS
© Copyright2012 - Design by ontwerps