• Resolved Dan.LaSota

    (@danlasota)


    <?php
    	global $wpdb;
    	global $wp_query;
    	$postID = $wp_query->post->ID;
    	$queryStr = "select meta_value from wp_postmeta where meta_key = 'sectionNav' AND post_id ='" . $postID . "';";

    I am executing this code outside the loop and am trying to figure out what the current postID is of the page being drawn.

    The code above returns the postID from searches, however.
    http://www.mysite.com/s=searchTerm
    (for instance).

    What reliable way is there to determine if the page being drawn has a particular metakey? (The code above on search pages seems to return a postID, that is the problem).

Viewing 1 replies (of 1 total)
  • Thread Starter Dan.LaSota

    (@danlasota)

    is_search() works with

    <?php if (!is_search()) {
    	global $wpdb;
    	global $wp_query;
    	global $post;
    	$postID = $wp_query->post->ID;

Viewing 1 replies (of 1 total)
  • The topic ‘What Post? Or is this a search Page?’ is closed to new replies.