Enhance WordPress by capitalizing post and page titles (h1 – h6)
P粉023326773
P粉023326773 2023-09-09 11:08:11
0
1
469

I want to create a function that will capitalize (the first letter of each word is capitalized) in the title of my WordPress site.

I have been able to develop a regular expression for filtering preg_match_all().

The question is how to iterate the matches and capitalize the title using the ucwords() function. Finally, insert the uppercase title into the content.

I tried this code. The question is how to proceed afterif (is_array())

function headings_in_the_content($content) { $regexpattern = '#(?P<(?Ph\d)(?P[^>]*)>(?P[^<]*))#i'; if (preg_match_all($regexpattern, $content, $matches)) { foreach ($matches as $regexmatches) { if (is_array($regexmatches)) { foreach ($regexmatches as $regexmatch) { } } } } return $content; } add_filter('the_content', 'headings_in_the_content', 15000);

P粉023326773
P粉023326773

reply all (1)
P粉600845163

If it was just for styling purposes, I would use css text-transform instead.

https://developer.mozilla.org/en -US/docs/Web/CSS/text-transform

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!