Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

While my related question on Stack Overflow should explain the basic CSS for this once it gets answered, how would I define a custom font family for a wordpress blog that will only apply to a <span> and will not affect the site-wide font families being used by the theme on my wordpress site?

Related: Creating Useable Custom Font Family

share|improve this question

1 Answer

up vote 1 down vote accepted

You can use this function: http://codex.wordpress.org/Function_Reference/body_class

Use this in your header.php

<body <?php body_class(); ?>>

This gives each page a different class and so you can use CSS to set the font-family for a specific page like so:

body.blog span.yourClassName{ font-family:; }

Then of course the is also the jQuery solution using the .children() function

share|improve this answer
What I specifically want to do is not apply to the entire body, or a page, but specifically within a <span> element, for targetted-formatting within a post. Is that even possible? (I did refer to the codex for this, and this was unable to fully encompass the use-case for this.) – The Lord of Time Aug 22 '12 at 19:19
Are you saying you want to apply classes to all elements within a specified element, or? – marcup Aug 22 '12 at 19:31
If you look at the code above closely you will see that the CSS rule selects all span's with a class of .yourClassName within the blog page only. – marcup Aug 22 '12 at 19:35
Per the related answer, my goal is to apply this to specific spans, for example: <span class="customclass">text</span> within wordpress posts. My question is mainly this: Do I need to worry about wordpress-specific formatting, or would adding the custom font-family, and then specially-defining span .customclass within the template/theme's CSS code as I would to a normal site be sufficient to apply the changes? – The Lord of Time Aug 22 '12 at 19:36
marcup, i had old information, you appeared to have edited, so that answers my question. Thanks! :) – The Lord of Time Aug 22 '12 at 19:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.