The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End PHP passing requested post id and title in url but not showing id

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #146172

    What’s the best way to achieve this? I’d like to have a forum with the post page displaying a url like The problem is I want to look up the post in the database by it’s id instead of title because I’ve read that looking up by title is slow especially if you have a lot of posts.

    So to achieve this you would have to pass the title (or a slug of it) and the id, that’s what I currently have. I have my .htaccess set up to rewrite to Now I just want to remove the id from the url, but I don’t know how… Any help please?



    You would have to provide more details about the CMS you are using.

    As you have stated, ID based lookups are recommend, because:

    1) numeric comparisons are faster than string comparisons
    2) the ID field is almost certainly indexed in the database, which will make it much faster to lookup

    Your CMS almost certainly provides a way to get the post ID without extra work, by way of a function or global(ish) variable.

    For example, in WordPress you can retrieve the post ID by using a function, called get_the_ID. You could assign it as such:

    $id = get_the_ID();

    And then query the database to your liking.


    Not nice :(


    No, no, you misunderstood. It was directed at Jochim for posting the same thing twice, at two very different time intervals.


    ah. Well, he may have had reason to. why I was asking.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘Back End’ is closed to new topics and replies.