WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Getting a post by parsing a link - HOW? (3 posts)

  1. Wabsnasm
    Member
    Posted 1 year ago #

    I want to be able to inject fields from one post into another using a shortcode. I thought a good way to do this would be to have the user insert a link to the page, like this:

    [shortcode]Link - to - http://example.com/taxonomy/term/post-name[/shortcode]

    I want to parse that link using something like WP->parse_request(), however that won't do it. How can I parse a URL and get its post (or even just its ID)?

    Is there another way to inject one post's content into an arbitrary point in another?

  2. Pioneer Valley Web Design
    Member
    Posted 1 year ago #

    This previous post notes such a method to get the post id (from a slug):

    http://wordpress.org/support/topic/post-id-from-slug?replies=7

  3. Wabsnasm
    Member
    Posted 1 year ago #

    Ok, thanks. I think it's not exactly what I'm after (mine can be one of several post-types) but from it I saw that I might be able to use get_page_by_title() by parsing the first part of the url as the post-type, and the second as the slug to look for...

    I would have thought that this would be VERY easy, seeing as WordPress already gets the current post by parsing the URL.

Topic Closed

This topic has been closed to new replies.

About this Topic