I’m writing a WP plugin that involves using shortcode. One of the missions is to display all (publish) posts that contain my shortcode regardless of their post type. Is there a built-in function for this?
Thanks in advance.
I’m writing a WP plugin that involves using shortcode. One of the missions is to display all (publish) posts that contain my shortcode regardless of their post type. Is there a built-in function for this?
Thanks in advance.
You must be logged in to post a comment.
WordPress isn’t aware of your shortcode until it’s rendered on the front end. So when WP sees it in the content and replaces it, that’s when it’s aware that your shortcode exists. It also promptly forgets about it afterward, of course.
So there’s no built in function to do what you’re asking. The best you can do is probably write a
LIKE
query which may or may not be a good idea.