Very quickly upon diving into the world of programming you’ll discover than conditions and logical arguments are essential to the majority of tasks you’ll do. One of the very first things you’ll come across is the If / Else statement. An example would be “If user is admin display post statistics else display advert”. A simple premise, but can be be tailored to be used in countless situations. Here’s a coded example:

add_action( 'init', 'create_post_type' );
function create_post_type() {
  register_post_type( 'svg',
      'labels' => array(
        'name' => __( 'SVGs' ),
        'singular_name' => __( 'SVG' ),
      'parent' => __( 'Assets' ),
      'public' => true,
      'has_archive' => true,
        'hierarchical' => true,
        'supports' => array( 'thumbnail','title','editor','page-attributes','revisions','author','trackbacks','post-formats' )

That’s the way I typically do it! However there is a shorthand way! Here goes:

Leave a Reply