get_header_image() returns null

While working on a theme in wordpress 3.4.2, I realised that wordpress function get_header_image() returns null in a ‘mu-plugins’ plugin even though in the theme’s functions.php file I’ve set a ‘default-image’ like this: add_theme_support( ‘custom-header’, array( ‘default-image’ => get_template_directory_uri() . ‘/subdir/default-header-image.jpg’ ) ); In the theme template file header.php, I’ve called get_header_image(), and it returns … Read more

WordPress Tinymce Dialogs

If you are trying to implement tinymce for your theme options page or plugins and the Insert/edit link doesn’t pop up the dialog after the button is clicked, try this: add_action( ‘admin_print_footer_scripts’, ‘wp_tiny_mce_preload_dialogs’, 30 ); add_action( ‘tiny_mce_preload_dialogs’, ‘wp_link_dialog’, 30 ); This worked for me as of version 3.1.3.

Converting HTML entities to characters

I was trying to use WordPress post titles as email subject headers in such a way: $subject = get_the_title(); wp_mail( $to, $subject, $message); However this became a problem when the post title included smart quotes, em-dash, ellipsis and the likes of them. My email subject ended up looking like this: Hey – This is my Post’s Title where … Read more

PHP Dynamic Variables

This is otherwise known as “Variable variables”. Let’s begin. Basically in PHP, we assign value to a variable like this: $var = “word”; If we want a variable whose name is the value of the $var variable, we do so like this: $$var = “press”; // $word = “press” PHP parses $$var by first de-referencing … Read more

WordPress 3.1 and setup_postdata

After upgrading one of my websites to WordPress to version 3.1, the loops that contained setup_postdata() created a mess. After some testing, I realised that setup_postdata() will only return the correct data if the argument passed is $post, i.e. setup_postdata($post). I had used setup_postdata( $ancestor ) instead and it created a mess after the upgrade. … Read more