I'm looking for the best way to obtain this.
For example, I have the h1 tag whic is: Web Design
I want to add, in all the h1 tags of a certain post type, the same word at the beginning, which is my keyword. So, the result would be: MYKEYWORD Web Design
I have clear that I have to use the_content filter. I have this code:
add_filter( 'the_content', 'handle_h1' );
function handle_h1( $content )
{
//check if it's the post type which I look for
if ( 'MYPOSTTYPE' != get_post_type() )
return $content;
return str_ireplace( '<h1', '<a href="#">Back to the top</a><h1', $content );
}
The example above adds the a href tag before the h1 tags...
Which I want is to change the output text of the h1, as I mentioned above.
EXAMPLE:
Original:
<h1>Books</h1>
What I want
<h1>Our Books</h1>
So the word added is "Our".
h1
HTML tag that wraps anything in your content (not the post type title or other parts)?