WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am developing a plugin, and I want to display a page that lists every page on the site that is using a specific shortcode defined by my plugin.

I assume that I need to manually search wp_posts, but I am curious if there is a built in function or a better way to do this.

Thanks so much!

share|improve this question
up vote 1 down vote accepted

You can specify a search term in a WP_Query or get_posts() call:

$pages = get_posts(
    array (
        's'         => '[shortcodename',
        'post_type' => array ( 'page', 'post' )
share|improve this answer
Can this handle multiple search terms? '[shortcode' and a parameter with the shortcode. (I'd just do '[shortcode id=#', but there could be multiple parameters in any order). – Jacob Raccuia Jun 10 '13 at 0:30
Yes, it should. Not sure what happens when only the parameters are found on page, but not the shortcode. Try it. – toscho Jun 10 '13 at 0:32
I ran into the problem that id="1", id='1', and id=1 are all possible parameters, but are selective in search. Do you have any other ideas? Otherwise, this is working nicely, but I need some sort of this, this, or this for the id. – Jacob Raccuia Jun 10 '13 at 1:43
As a work around, I'm going to just search for the shortcode, and search the array after that. Thank you! – Jacob Raccuia Jun 10 '13 at 1:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.