Add button to TinyMCE bar without creating a plugin

It is almost code golf, but this is the smallest piece of code that I could up with that will create a button on the Visual editor to turn the current paragraph in a <h2> block. add_filter( ‘tiny_mce_before_init’, ‘wpse18719_tiny_mce_before_init’ ); function wpse18719_tiny_mce_before_init( $initArray ) { $initArray[‘setup’] = <<<JS [function(ed) { ed.addButton(‘h2’, { title : ‘H2’, … Read more

Custom maintenance page

When WordPress goes into maintenance mode, it adds a file named .maintenance to the root directory while the maintenance is being performed, then it’s removed afterwards. You can write a function inside your theme’s functions.php that checks for this file and loads a custom maintenance page from the theme. if ( ! function_exists( ‘wpse84987_maintenance_mode’ ) … Read more

Make Custom Metaboxes Collapse by Default

To display a metabox collapsed or closed by default, it is good to know that adding closed to it’s class attribute will display it closed. All meta-boxes main divs that have closed in their classname, are displayed in the closed form. When the arrow is clicked it will be removed or added (toggled). This is … Read more

How to Change 404 page title

I would use the wp_title filter hook: function theme_slug_filter_wp_title( $title ) { if ( is_404() ) { $title=”ADD 404 TITLE TEXT HERE”; } // You can do other filtering here, or // just return $title return $title; } // Hook into wp_title filter hook add_filter( ‘wp_title’, ‘theme_slug_filter_wp_title’ ); This will play nicely with other Plugins … Read more

How do you get formatted content of a post using the WordPress API?

Post’s object field contains raw content as it is stored in database. This should format it to how it appears when retrieved with template tags: $content = apply_filters(‘the_content’, $content); This filters runs number of formatting functions, including shortcodes parsing. Something close to this: >>>>> the_content 8 (object) WP_Embed -> run_shortcode (1) (object) WP_Embed -> autoembed … Read more

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