I want to redirect users to a page on which a particular short-code has been used after they login. So basically I want to know how can I get the permalink of that particular page on which my plugins specific short code has been used?
1 Answer
I think that the very best approach would be to store that page on a option.
Anyway, if you want to get the pages where a shortcode has been used, you can use the search parameter (s
) of WP_Query
class (or get_posts()
function). Basically, this parameter performs a LIKE
query, so it could be useful to search for shortcodes like this:
$args = array(
's' => '[myshortcode',
'post_type' => 'pages'
);
$pages_with_myshortcode = get_posts( $args );