Skip to main content
added 80 characters in body
Source Link
Brad Dalton
  • 7k
  • 2
  • 36
  • 47

You can then use CSS to display your featured images in a inline grid style.

You can then use CSS to display your featured images in a inline grid style.

Source Link
Brad Dalton
  • 7k
  • 2
  • 36
  • 47

WordPress generates an archive page when your register the CPT. As stated you can modify posts per page from your functions file and register both the CPT and Taxonomy support using this code:

add_action( 'pre_get_posts', 'set_items' );
function set_items( $query ) {

    if( $query->is_main_query() && !is_admin() && is_post_type_archive( 'tn_cstm_sketchbook' ) ) {
        $query->set( 'posts_per_page', '12' );
    }



    // Register Custom Post Taxonomy
add_action( 'init', 'create_work_taxonomies' );               
function create_work_taxonomies() {
                register_taxonomy(
                    'tn_cstm_sketchbook_plugin',
                    'tn_cstm_sketchbook',
                    array(
                        'labels' => array(
                            'name' => 'Sketchbook Categories',
                            'add_new_item' => 'Add New Sketchbook Category',
                            'new_item_name' => "New Sketchbook Category"
                        ),
                        'show_ui' => true,
                        'show_in_nav_menus' => true,
                        'show_admin_column' => true, //Show custom taxonomy in admin columns
                        'show_tagcloud' => false,
                        'hierarchical' => true,
                        'args' => array( 'orderby' => 'term_order' ),
                        'rewrite' => array('slug' => 'sketchbook-categories', 'with_front' => false )
                    )
                );
            }
    
    
        // Register Custom Post Type
add_action( 'init', 'create_sketchbook_work' );        
function create_sketchbook_work() {
                register_post_type( 'tn_cstm_sketchbook',
                    array(
                        'labels' => array(
                            'name' => 'Sketchbook',
                            'singular_name' => 'Sketchbook Page',
                            'add_new' => 'Add New Sketchbook Page',
                            'add_new_item' => 'Add New Sketchbook Page',
                            'edit' => 'Edit Sketchbook Page',
                            'edit_item' => 'Edit Sketchbook Page',
                            'new_item' => 'New Sketchbook Page',
                            'view' => 'View Sketchbook Page',
                            'view_item' => 'View Sketchbook Pages',
                            'search_items' => 'Search Sketchbook Pages',
                            'not_found' => 'No Sketchbook Pages found',
                            'not_found_in_trash' => 'No Sketchbook Pages Found in Trash',
                            'parent' => 'Parent Sketchbook Page'
                        ),
    
                        'public' => true,
                        'show_in_menu' => true,
                        'menu_position' => 29,
                        'taxonomies' => array( '' ),
                        'menu_icon' => plugins_url( 'images/sketchbook-icon.png', __FILE__ ),
                        'publicly_queryable' => true,
                        'query_var' => true,
                        'rewrite' => array( 'slug' => 'sketchbook', 'with_front' => false ),  
                        'has_archive' => true,
                        'hierarchical' => false,
                        'supports' => array( 'title', 'page-attributes' )
                    )
                );
            }

No need for any custom query or CPT archive and you wouldn't use a template for the archive as WordPress uses the Template Hierarchy