Add theme support – basics
add_theme_support is very important functions for developing themes. Thanks to this function, you may add many cool features to your theme. And forget about title tag in your templates (since WordPress 4.1). Important notice: add_theme_support must be called before “init” hook is fired, because it is too late for some features. Use “after_setup_theme” hook or just put functions calls straight in your functions.php file. Example 1: functions.php [crayon-641f5c57bd7b0121806489/] Example 2: after_setup_theme hook [crayon-641f5c57bd7b8551554619/]
WordPress tables part 1
Some of you knows, that I write the book about WordPress programming. It is very slow process and I’m not even sure if I finish it this year. Of course I will try. While this process, I needed WordPress tables (I named it after mathematical tables, very popular before cheap-calculator arrived). So, I will try to give you a sample of it. WordPress actions muplugins_loaded registered_taxonomy (for “category”) registered_taxonomy (for “post_tag”) registered_taxonomy (for “nav_menu”) registered_taxonomy (for “link_category”) registered_taxonomy (for “post_format”) registered_post_type (for “post”) registered_post_type (for “page”) registered_post_type (for “attachment”) registered_post_type (for “revision”) registered_post_type (for “nav_menu_item”) plugins_loaded sanitize_comment_cookies setup_theme unload_textdomain (for “default”) load_textdomain (for “default”) after_setup_theme auth_cookie_malformed auth_cookie_valid set_current_user init registered_post_type…
Post class and Body class with WordPress
Classes in WordPress are important and commonly forgotten (in poor themes) elements. There are two main roles for classes, body class and post class. Of course we may get different post class set for each post. Body class body_class() is a shortcut for get_body_class() function. The easiest method to use it, is: [crayon-641f5c57be013428749525/] Of course we may add our custom class, to do that, just put it as a string or an array. You may do that like this: [crayon-641f5c57be019162640224/] or like this: [crayon-641f5c57be01a294771860/] The result will be absolutely the same. Of course you may use get_body_class() function, but you need to do something more. Like this: [crayon-641f5c57be01c079493168/] or like…
How to hide toolbar (admin bar)?
Well, I like toolbar (note, that we call it toolbar, since WordPress 3.3 as far as I remember, we called it admin bar before that) and I do not need to hide it, but I know many people wants to. So, here is very simple code to do that thing: [crayon-641f5c57be20f972418858/] Please note, that this line will hide toolbar only on front-end! If you want to hide it on both frontend and in the admin panel (for god’s sake, why?) do that: [crayon-641f5c57be214825911695/] As easy as is.
First security release – WordPress 4.6.1
Well, I wrote first, because every single piece of software has some errors and needs to be updated. What is good about WordPress – we get updates as soon as they are available. So, today we got WordPress 4.6.1 available to download, have fun! Fifteen bugs are fixed and ready to go on your site 🙂