[wp-hackers] Get URL of page with shortcode
Jeremy Clarke
jer at simianuprising.com
Wed Feb 2 07:22:41 UTC 2011
On Wed, Feb 2, 2011 at 1:59 AM, Ryan Bilesky <rbilesky at gmail.com> wrote:
> That would just link me to the current page, I need to get the link to the
> page with a specific shortcode. I was just wondering if there is a more
> correct method than using wpdb to query for the id where content =
> myshortcode.
>
>
This is probably something you should use a postmeta value for instead of a
shortcode, considering how you want to fetch it.
If you need to use a shortcode then the easiest way is probably using a
search query with new WP_Query(), and searching for the most common part of
your shortcode. That will return all posts with the shortcode and not just
one, but unless you are somehow enforcing that only one post can have the
shortcode you should assume more than one does.
--
Jeremy Clarke • jeremyclarke.org
Code and Design • globalvoicesonline.org
More information about the wp-hackers
mailing list