i'm creating a wordpress plugin for wordpress. In the beginning, i had been accounting using the default configurations, in which the Link to a publish could be http://localhost/worpress/?p=123, and that i was requesting is_single() within the wp_footer action.

When my wordpress plugin was ready, i went to try and cleanup my code. You will find (a minimum of) a couple of things that i am getting wrong:

  1. How come it return false, after i request for is_single() within the init action or something like that earlier than wp_footer?
  2. Why, after i consider using a var_dump($_REQUEST) (or _Publish, or _GET) any place in my page cycle, i recieve a clear array, after switching the permalink choices to url_friendly type?

Can anybody shed an easy about this, please?

Question 1:

  • is_single() is only going to return true if you're on one publish
  • the init action hook happens really at the start of the cycle should you call is_single prior to the Wordpress_Totally instantiated you will get false.

To determine whether you are calling is_single too soon set define('WP_DEBUG', true); in wp-config.php. This really is online 81 of my version of wordpress-config. You will notice a mistake message from WordPress if you are calling it too soon. (Plus it is a good tool to make use of throughout development.)

Question 2:

You are not receiving $_REQUEST parameters after switching to friendly URL's because friendly Web addresses do not have a querystring (the title/value pairs that occur following the question mark in something similar to http://localhost/worpress/?p=123.) Observe that http://localhost/worpress/foo/bar does not possess a question mark.