Span tag in page/post title - Customizing page/post title
This shows up from time to time and I now have a client who wants the first word of his page titles formatted differently from the remainder of the title..
I actually have come across something that was posted on wordpress.org that looks like it would work, actually it does, just too well! From the post... ...for just the page title, edit page.php and replace the_title(); with: Code:
$words = explode(' ', the_title('', '', false)); or for generally all titles (this will add the span around the first word in any title, such as post titles, page titles, and the_title is also used for instance in page lists) - add something like this to functions.php of your theme: Code:
add_filter('the_title', 'span_first_word'); It's pretty much no muss no fuss. The "add filter" works like a charm for what I want, but of course it messes up any other usage of "the_title();", including the WordPress drag and drop menu. And of course, my client insists on the WP menu. So my question is - Is there a way to wrap the function so that it will only be active in a post or page and not other places that "the_title();" is used? If not, I'll probably just have to go with the first method and figure out where to modify the template, as much as I'd rather not. Any thoughts? |
create a CSS insert
HTML Code:
.myred {color: red;} HTML Code:
<span class="myred">First</span> word will be colored red First word will be colored red |
Hi Juggledad,
Yes, that's true! And it works fine... Unless you have selected ATA's "Use Page/Post Options". Atahualpa overides WordPress' the_title()tag with it's own functions and strips html tags from the title. If using the WordPress drag 'n drop menu, ATA adds a span tag inside the page title link. Ultimately, what I'm trying to do is be able to be able to put html in *only* the h1 titles used on pages and posts. The above functions code that I pasted does what I want on pages/posts but messes up the d 'n d menu and I haven't checked but probably any other use of the title (widgets, etc.) Do you know of a way to do what I want to do? My preference would be from the functions.php but I'm open to whatever works with using the ATA's "Use Page/Post Options" active. |
just use '"' in place of the double quote like this
HTML Code:
<span class="myred">page</span> with a big title |
This should not be too difficult IF you are NOT using the Atahualpa Post options
The code for the page/post titles is in bfa_post_parts.php in teh function 'bfa_post_headline' |
Absolutely JD!
It would have been a slam-dunk if my client wasn't insisting on my using the WordPress drag 'n drop menu function. Slowly but surely I'm trying to work my way through Atahualpa 'title" coding usage to see if it can be done. <sigh> |
if they aren't using the Atahualpa page/post options (ato->Configure SEO->Use Post / Page Options?) then there are just 2 places in teh code that uses 'the_title()' - you could just put the code there. (lines 37 and 40 in version 3.7.7)
|
Sorry JD, I should have added that they *also* want the features provided by the ATA "use post/page options".
It may well be that they just don't get everything they want... Ken |
FYI I took a look at that code thinking about redesigning it and realized it was going to take a good two/three hours to recode it and test it for all cases. You have to take care of the case where
1) use the WP title with a link 2) use the WP title with NO link 3) a case where they don't enter a WP title (it is blank) 4) use the ata single post title 5) use the ata single post title as a link 6) the use the ata multi post title 7) the use the ata multi post title as a link I think those are all the cases...this is why it is complex |
All times are GMT -6. The time now is 04:34 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.