admin管理员组文章数量:1326344
Brand new to this community but been tinkering with WordPress for years.
I would like to edit my website's functions.php file to be able to automatically do a task I have to do manually each day.
Basically, everyday I write a discussion with 5-20 paragraphs. At the beginning of each paragraph, I always lead with "PARAGRAPH TITLE HERE..." (without the quotes), so the discussion looks like this:
WHO LET THE DOGS OUT... Paragraph text here describing who actually let the dogs out. I wonder who let the dogs out. Long paragraph text here.
I AM EATING A RAISIN... Yes, raisins are supposedly good for you. Lots of sugar, but good. Raisins are made from grapes.
Basically, I want the functions.php file to make the words before the three dots uppercase in every post I do. What is the most effective way for me to accomplish this? Thank you!
Brand new to this community but been tinkering with WordPress for years.
I would like to edit my website's functions.php file to be able to automatically do a task I have to do manually each day.
Basically, everyday I write a discussion with 5-20 paragraphs. At the beginning of each paragraph, I always lead with "PARAGRAPH TITLE HERE..." (without the quotes), so the discussion looks like this:
WHO LET THE DOGS OUT... Paragraph text here describing who actually let the dogs out. I wonder who let the dogs out. Long paragraph text here.
I AM EATING A RAISIN... Yes, raisins are supposedly good for you. Lots of sugar, but good. Raisins are made from grapes.
Basically, I want the functions.php file to make the words before the three dots uppercase in every post I do. What is the most effective way for me to accomplish this? Thank you!
Share Improve this question edited Aug 11, 2020 at 5:24 Nate Allen 2,1062 gold badges16 silver badges23 bronze badges asked Jul 31, 2020 at 21:47 radioman10radioman10 111 bronze badge1 Answer
Reset to default 1Welcome to WPSE.
So I can't write all the code for you, but I would suggest you look at these main pieces, and then come back here or make new questions if you have followup questions:
To alter the content of a post before it's printed to the screen you could use the
the_content
filter. This lets you make any changes you want at all to the content section of a post (or page) before it's printed to the screen, and return it with any changes to wherever is trying to print it.Then you have to find the part you want and only change that part. This is more of a PHP question, but for example this snippet of code will take a string with
...
in it and split it into two pieces around the...
:
$content = "TITLE HERE... Once upon a time";
$pieces = explode("...", $content, 2);
// now $pieces is a PHP array with anything before "..." in $pieces[0]
// and anything after "..." in $pieces[1]
- Then you need to convert some of it to upper case, probably using the PHP function
strtoupper()
and put it back together. E.g. continuing from above:
$new_content = strtoupper($pieces[0]) . "..." . $pieces[1];
Note: It's not a very clearly drawn line, but Item 1 is the main WordPress part, Items 2 and 3 are more PHP questions which should be directed to e.g. stackoverflow.
HTH and happy to help further, to make best use of this StackExchange is best to make a start on some piece of the code and ask specific questions about where you get to.
本文标签: functionsUppercase first sentence in every post
版权声明:本文标题:functions - Uppercase first sentence in every post 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742197070a2431273.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论