• Resolved remus

    (@remus)


    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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    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.

    Thread Starter remus

    (@remus)

    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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How WP requests posts IDs while permalinks are ON?’ is closed to new replies.