forked from braddalton/divi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
58 lines (46 loc) · 1.66 KB
/
functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
//* Create Portfolio Type custom taxonomy
add_action( 'init', 'divi_type_taxonomy' );
function divi_type_taxonomy() {
register_taxonomy( 'portfolio-type', 'portfolio',
array(
'labels' => array(
'name' => _x( 'Types', 'taxonomy general name', 'divi' ),
'add_new_item' => __( 'Add New Portfolio Type', 'divi' ),
'new_item_name' => __( 'New Portfolio Type', 'divi' ),
),
'exclude_from_search' => true,
'has_archive' => true,
'hierarchical' => true,
'rewrite' => array( 'slug' => 'portfolio-type', 'with_front' => false ),
'show_ui' => true,
'show_tagcloud' => false,
)
);
}
//* Create portfolio custom post type
add_action( 'init', 'divi_portfolio_post_type' );
function divi_portfolio_post_type() {
register_post_type( 'portfolio',
array(
'labels' => array(
'name' => __( 'Portfolio', 'divi' ),
'singular_name' => __( 'Portfolio', 'divi' ),
),
'has_archive' => true,
'hierarchical' => true,
'menu_icon' => 'dashicons-portfolio',
'public' => true,
'rewrite' => array( 'slug' => 'portfolio', 'with_front' => false ),
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'revisions', 'page-attributes' ),
'taxonomies' => array( 'portfolio-type' ),
)
);
}
//* Change the number of portfolio items to be displayed (props Brad Dalton)
add_action( 'pre_get_posts', 'divi_portfolio_items' );
function divi_portfolio_items( $query ) {
if( $query->is_main_query() && !is_admin() && is_post_type_archive( 'portfolio' ) ) {
$query->set( 'posts_per_page', '12' );
}
}