What I’m trying to achieve is a simple text-replace functions, that would be available to any site in my WordPress Network. Basically I want to:
-
Change
[--]
into—
(—), -
Be able to link to my own posts using only their titles —
[internallink post=title]
or anything similar.
I found simple example of solving this using shortcodes. But I don’t know, where to put my custom shortcodes definition, so it would be available to any site in my WordPress Network.
I’m always looking into solutions as simple as possible, so I would like to know, if I have to use shortcodes to solve these two tasks or:
-
Is there an easy way to define global search & replace mechanism, so any occurence of just
--
would be changed to—
in any post or page on any site in the network? -
Is there anyway to define global shortcode function, that would convert any
[post title]
into link poiting to post titled “Post Title”?
Thank you in advance for any help here?
To have a Network enabled shortcode, you only need a Must Use plugin. Just create the folder
/wp-content/mu-plugins
and drop your code there. From the Codex:The search and replace issue seems a bit more sensitive and maybe this plugin can be of use: Search and Replace and do it only in the
post_content
field. You can also use the filterthe_content
, search this site for various examples on how to deal with it.