Support » Fixing WordPress » How to get the Querystring ($_GET) when using Permalinks?

  • Hi,

    I’m using WordPress 2.0.1. Using the normal link system (blog/?page_id=123 ) I can easily get to the querystring (via $_GET[page_id]).

    However, using the Permalink system (blog/2006/03/09/sample-post/) this no longer works – the entire $_GET array disappears!

    Anyone know how I can access it using Permalinks?

    Many thanks in advance,


Viewing 6 replies - 1 through 6 (of 6 total)
  • The querystring for a Page under a custom permalink structure would be 'pagename'; for posts, 'name' (or 'p' if the permalink structure uses %post_id% instead of %postname%).

    Hi Kafkaesqui,

    Thanks very much, you’re right the variable $pagename or $name gives me the URI for the page (eg. contact-us).

    However, what I would really like is the ID of the page (eg. 9).

    Any idea how I can get this?

    Many thanks,


    try $_REQUEST[‘page_id’]

    Try this to collect the ID (should work for both Page and post):

    global $wp_query;
    $id = $wp_query->post->ID;

    Thanks Kafkaesqui that worked perfectly!

    $id = $wp_query->post->ID; works fine, but why does the index-page always give me the ID of the latest post? For statistics the request of the index-page is not the same as the latest post! How can I prevent this?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to get the Querystring ($_GET) when using Permalinks?’ is closed to new replies.