-
Notifications
You must be signed in to change notification settings - Fork 0
/
charta-vitae.php
52 lines (48 loc) · 1.69 KB
/
charta-vitae.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
<?php
/**
* Plugin Name: Charta Vitae
* Plugin URI: https://github.com/Nate-Wessel/charta-vitae
* Description: Map your post metadata
* Version: 0.1
* Author: Nate Wessel
* Author URI: https://natewessel.com/
* License: GPL3
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
*/
# prevent abuse:
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
include_once('entities/projects.php');
include_once('entities/collaborators.php');
include_once('entities/tags.php');
include_once('enable-shortcodes.php');
include_once('JSON-API.php');
add_filter( 'template_include', 'cv_templates' );
function cv_templates( $template ) {
$plugin = 'wp-content/plugins/charta-vitae';
if( is_singular() && get_post_type() == 'cv_project' ){
wp_enqueue_style('CVstyle',"/$plugin/charta.css");
return "$plugin/templates/single-cv_project.php";
}elseif( is_singular() && get_post_type() == 'cv_collaborator' ){
wp_enqueue_style('CVstyle',"/$plugin/charta.css");
return "$plugin/templates/single-cv_collaborator.php";
}elseif( get_post_type() == 'cv_project' ){
wp_enqueue_style('CVstyle',"/$plugin/charta.css");
return "$plugin/templates/archive-cv_project.php";
}elseif( get_post_type() == 'cv_collaborator' ){
wp_enqueue_style('CVstyle',"/$plugin/charta.css");
return "$plugin/templates/archive-cv_collaborator.php";
}
return $template;
}
add_action( 'pre_get_posts', 'cv_change_sort_order');
function cv_change_sort_order($query){
// change sort order of archive pages listing projects
if(
$query->is_main_query() &&
( is_post_type_archive('cv_project') || is_tax('cv_tag') )
){
$query->set('orderby',['meta_value'=>'DESC']);
$query->set('meta_key','start');
}
}
?>