Forums

get_post_by_path? (3 posts)

  1. wuchschba2
    Member
    Posted 4 months ago #

    Hello! I'm new to Wordpress but got a lot of experience in programming of php. I'm wirting a plugin right now, which developed easy and straight forward so far.

    But now I came over an odd thing: I needed to get a category from an URL, so I used get_category_by_path. Fine

    But what do you do if you got a URL from a post and you need the post-id? I'm missing a method get_post_by_path.

    The only way I found out I could find a post by an URL is to query the database - but why should there be a method for the categories but not for posts? Can you help me please? Thanks a lot!

  2. MichaelH
    moderator
    Posted 4 months ago #

    There is the template tag, query_posts():

    query_posts('name=about-my-life');

  3. wuchschba2
    Member
    Posted 4 months ago #

    Ah, thanks a lot!

Reply

You must log in to post.

About this Topic