WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How WP requests posts IDs while permalinks are ON? (3 posts)

  1. remus
    Member
    Posted 5 years ago #

    Hello,

    I need to create a plugin and this really has to work with the permalinks on. Anyways, while on the default "ugly" URLs, the method is to $_GET posts and pages IDs but (sorry if this is a stupid question) how are the pages, categories and posts IDs requested when the permalinks are ON?

    If you try to display that with print_r($_REQUEST) nothing is showing but the pages and posts are working?

    I am trying to build a custom permalink formats in order to bring in extra variables into the equation.

    Thank you for your time and answers!

    Best regards
    Remus.

  2. Samuel Wood (Otto)
    Tech Ninja
    Posted 5 years ago #

    For all cases, use code like this:
    $var = get_query_var('whatever');

    Where "whatever" is the info you want. Like if you wanted the post id:
    $postid = get_query_var('p');

    Or the page id:
    $pageid = get_query_var('page_id');

    Don't use _GET and such, they're unreliable.

  3. remus
    Member
    Posted 5 years ago #

    Thank you for your suggestion, it is very helpful ! This will help me a lot developing the plugin. I will be very happy to share with the community once it's going be working and stable.

    Thanks once again!

    Best,
    Remus.

Topic Closed

This topic has been closed to new replies.

About this Topic