Search and replace words with code
-
Here’s what I want to accomplish:
Baisically, I want a function that will scan through the text in a post, and at the first instance of a specific word on any given page, it will display a small side-text (that’s the small text on the right in the image). The list contains some fifty odd words with descriptions, all contained in a textfile.
I know that I need a plugin in order to force wp to push code into a post (as opposed to only allowing certain tags), but I’m curious if I should be using php for this or if javascript is better suited.
I guess this question could be divided into two parts:
1 – How do I add a description of specific words dynamically based on a seperate list of words?
2 – Is it possible to style the text to appear with the top aligned with the word?There will be trouble if too many words trigger the funtion in any given post, but that’ll be a later concern, and hopefully fixable through css (or php->css)
If anyone could let me know if this is at all worth the hassle, and which method I should consider, I would appreciate it greatly.
The topic ‘Search and replace words with code’ is closed to new replies.