Answers for "wp+create custom post type and category"

PHP
0

wp+create custom post type and category

add_action( 'init', 'create_news' );
function create_news ()
{      
    register_post_type( 'ecommerces',
                array(
                'labels'        => array(
                'name'          => __( 'Ecommerces' ),
                'singular_name' => __( 'Ecommerce' )
                ),
                'public'   => true,
                'supports' => array ('title', 'editor', 'thumbnail')
                )
                );

    register_taxonomy(
                'ecommerce_cat',
                'ecommerces',
                array(
                'labels' => array(
                'name' => 'Ecommerce Categories',
                'add_new_item' => 'Add New Ecommerce Category',
                'new_item_name' => "New Ecommerce Category"
                ),
                'show_ui' => true,
                'show_tagcloud' => false,
                'hierarchical' => true,
                'hasArchive' => true
                )
                );

    }

    if ( function_exists( 'add_theme_support' ) ) {
    add_theme_support( 'post-thumbnails' );
    set_post_thumbnail_size( 100, 100, true ); 
}

    ?>
Posted by: Guest on November-28-2020
2

create custom post type with category in wordpress functions.php

function create_posttype() {
  register_post_type( 'wpll_product',
    array(
      'labels' => array(
        'name' => __( 'Products' ),
        'singular_name' => __( 'Product' )
      ),
      'public' => true,
      'has_archive' => true,
      'rewrite' => array('slug' => 'products'),
    )
  );
}
add_action( 'init', 'create_posttype' );
Posted by: Guest on November-26-2020

Code answers related to "wp+create custom post type and category"

Browse Popular Code Answers by Language