Support » Plugins and Hacks » Php function: $pageID from slug?

  • I am trying to get the postID from a postSlug. Thought I could use “query_posts” to do this. I don get what is happening as I get content in the pageArray, but putting the following code int the template fails to print anything for “about_PageID”. I tried adding “setup_postdata”, but no joy. Any ideas?

    $pageArray = query_posts('pagename=about'); //retrieves the about page only
    $about_PageID = $pageArray->ID]
    echo "Page ID: " . $about_PageID;
    echo "<p></p>";

Viewing 1 replies (of 1 total)
  • $about_PageID = $pageArray[0]->ID;

    query_posts sort of creates an array of (object) arrays, so you have to pass the array key.

Viewing 1 replies (of 1 total)
  • The topic ‘Php function: $pageID from slug?’ is closed to new replies.