October 2018
Beginner
300 pages
8h 34m
English
Usually, we can use the WordPress global $post object in the post details page to get the necessary information about a post. Let's assume we want to get the ID of the loaded post within a plugin function to execute some tasks. Let's use the init action to print the post ID to the browser while accessing an individual post:
add_action( 'init', 'wpqal_init_action' );function wpqal_init_action() { global $post; print_r($post->ID);exit;}
We expect the post ID to be printed on the browser. However, we will get an empty output as the $post object is not loaded at this stage. So, we have to use an action executed later in the loading process. The global $post object is only accessible in the wp
Read now
Unlock full access