Repository navigation
Expand file tree
/
Copy pathworks.php
More file actions
57 lines (52 loc) · 1.38 KB
/
Copy pathworks.php
File metadata and controls
57 lines (52 loc) · 1.38 KB
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
/*
Plugin Name: Works
Plugin URI: https://greentiger.internetbravo.net/plugins/ctp
Version: 1.0
Author: Joao Alves Marrucho
Author URI: https://greentiger.internetbravo.net
License: GPL3
License URI: https://www.gnu.org/licenses/gpl.html
Text Domain: works
*/
function ctg_cpt_init() {
register_post_type( 'Works',
array(
'labels' => array(
'name' => __( 'Works' ),
'singular_name' => __( 'Work' )
),
'menu_position' => ('10'),
'public' => true,
'description' => ('Work'),
'has_archive' => true,
'taxonomies' => array('category'),
'menu_icon' => 'dashicons-format-image',
'supports' => array( 'title', 'editor', 'thumbnail')
)
);
}
add_action( 'init', 'ctg_cpt_init' );
function ctg_rewrite_flush() {
ctg_cpt_init();
flush_rewrite_rules();
}
register_activation_hook( __FILE__, 'ctg_rewrite_flush' );
add_filter( 'pre_get_posts', 'be_archive_query' );
function be_archive_query( $query ) {
if( $query->is_main_query() && $query->is_post_type_archive('works') ) {
$query->set( 'posts_per_page', -1 );
}
}
function works_install()
{
ctg_cpt_init();
flush_rewrite_rules();
}
register_activation_hook( __FILE__, 'works_install' );
function works_deactivation()
{
flush_rewrite_rules();
}
register_deactivation_hook( __FILE__, 'works_deactivation' );
?>