April 2019

Call register_sidebar() for each sidebar you want to create. # Define the ‘main-sidebar’. add_action( ‘widgets_init’, ‘my_register_sidebars’ ); function my_register_sidebars(){ register_sidebar( array( ‘id’ => ‘main-sidebar’, ‘name’ => __( ‘Main Sidebar’ ), ‘description’ => __( ‘Widgets in this area will be shown on all posts and pages.’ ), ‘before_widget’ => ‘<aside id=”%1$s” class=”widget %2$s”>’, ‘after_widget’ => ‘</aside>’,

Filter and Sanitize

September 2018

filter_input // Sanitize input if (is_numeric($_POST[$post_key])) { $filtered_db_inputs[$post_key] = filter_input(INPUT_POST, $post_key, FILTER_SANITIZE_NUMBER_INT); } else { $filtered_db_inputs[$post_key] = filter_input(INPUT_POST, $post_key, FILTER_SANITIZE_STRING); } Trimming Use trim, ltrim, and rtrim to remove substrings from the beginning and end of a string. $string = ‘ _hello_ ‘; $trimmed = trim( $string ); // Returns “_hello_” echo trim( $trimmed, ‘_’

Semantic HTML

September 2018

<body> <header> <div id=”logo”>…</div> <nav role=”navigation”> <ul> <li><a href=”/”><span>Home</span></a></li> <li><a href=”/archives/”><span>Archives</span></a></li> <li><a href=”/about/”><span>About</span></a></li> <li><a href=”/contact/”><span>Contact</span></a></li> </ul> </nav> </header> <main role=”main”> <h1>…</h1> <p>…</p> <article> <header> <h2>…</h2> <p>…</p> </header> <p>…</p> <section> <h3>Comments</h3> <article> <header> <h3>…</h3> <p>…</p> </header> <p>…</p> </article> </section> </article> … </main> </body> </html>   More Resources W3C Sections Recommendation ( Semantics in HTML5 ( HTML5

Custom Taxonomies in WordPress

November 2015

Define a Custom Taxonomy add_action( ‘init’, ‘ww_create_taxonomies’ ); function ww_create_taxonomies() { // Add new taxonomy, NOT hierarchical (like tags) register_taxonomy( ‘ww_languages’, // Unique ID for the “Languages” taxonomy. (always use a prefix) ‘ww_products’, // The post-type(s) this taxonomy can be applied-to . array( ‘hierarchical’ => false, ‘labels’ => array( ‘name’ => _x( ‘Languages’, ‘taxonomy general