Hook for post and page load

You can use the wp hook and check the global $wp_query object or any conditional. add_action( ‘wp’, ‘wpse69369_special_thingy’ ); function wpse69369_special_thingy() { if ( ‘special_cpt’ === get_post_type() AND is_singular() ) return print “Yo World!”; return printf( ‘<p>Nothing to see here! Check the object!<br /></p><pre>%s</pre>’, var_export( $GLOBALS[‘wp_query’], true ) ); } See: wp in codex.wordpress.org and … Read more

GET the excerpt by ID

Hi @Robin I. Knight: I view get_the_excerpt() as a function with legacy design. As WordPress usage has grown there are many newer use-cases where it doesn’t fit but where the newer functions for getting different data do. One example is the now frequent use of an $args array of function options. But it’s easy to … Read more

Turn a URL into an Attachment / Post ID

Massively improved function developed for plugin heavy on images: if ( ! function_exists( ‘get_attachment_id’ ) ) { /** * Get the Attachment ID for a given image URL. * * @link http://wordpress.stackexchange.com/a/7094 * * @param string $url * * @return boolean|integer */ function get_attachment_id( $url ) { $dir = wp_upload_dir(); // baseurl never has a … Read more

When is the ‘post_content_filtered’ column in database cleared by WordPress?

Every post update in WordPress is handled by the wp_update_post function. This function has some defaults, and for post_content_filtered the default value is ” (empty string). Once the defaults are merged with args passed to function via wp_parse_args it means that every time a post is updated and post_content_filtered is not explicitly passed, it is … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)