How do I put the post title in a span that has a class using the the_title hook?
-
The wp-Typography plugin cannot use any classes from the HTML to exclude elements from the wp-Typography rules, because it doesn’t see the HTML.
So the span with a class must be in the_title, as meant by the_title hook.
The post title must be included in that span.And then I can declare that span at the exclusion rules of wp-Typography.
This is what I have currently:
function add_span($title, $id) { return $title .' <span class="title_span">' .get_post_meta($post_id, $key, $single) ."</span>"; } add_filter('the_title', 'add_span', 10, 2);
But this code assumes that I store my span as a meta value, but I am not.
I just want to put the title in a span with a class with the the_title hook, after it’s retrieved from the database.
What would be the correct code for that?Thanks!
Ah, would this be correct?
function add_span($title) { return $title .' <span class="title_span">'."</span>"; } add_filter('the_title', 'add_span', 10, 1);
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘How do I put the post title in a span that has a class using the the_title hook?’ is closed to new replies.