jeudi 16 avril 2015

Using multiple custom post types (Bones Theme)

I've made a custom content-type for my Bones Theme but when I try to add another custom content type my site stops working and only displays a blank page.


I think it has something to do with the require_once or the function name.


This is my function.php



require_once( 'library/team.php' );
require_once( 'library/partners.php' );


And this in my custom post PHP files.



function custom_post_team()
function custom_post_partners()


Is there something I'm doing wrong?


EDIT: Added the php from the the files.


Postype: "partners"



add_action( 'after_switch_theme', 'bones_flush_rewrite_rules' );


function bones_flush_rewrite_rules() {
flush_rewrite_rules();
}

function custom_post_partners() {

register_post_type( 'partners',

array( 'labels' => array(
'name' => __( 'Partners', 'bonestheme' ),
'singular_name' => __( 'Partners', 'bonestheme' ),
'all_items' => __( 'Partners', 'bonestheme' ),
'add_new' => __( 'Add New', 'bonestheme' ),
'add_new_item' => __( 'Add New Partner', 'bonestheme' ),
'edit' => __( 'Edit', 'bonestheme' ),
'edit_item' => __( 'Edit Post Types', 'bonestheme' ),
'new_item' => __( 'New Post Type', 'bonestheme' ),
'view_item' => __( 'View Post Type', 'bonestheme' ),
'search_items' => __( 'Search Post Type', 'bonestheme' ),
'not_found' => __( 'Nothing found in the Database.', 'bonestheme' ),
'not_found_in_trash' => __( 'Nothing found in Trash', 'bonestheme' ),
'parent_item_colon' => ''
),
'description' => __( 'Partners', 'bonestheme' ),
'public' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'show_ui' => true,
'query_var' => true,
'menu_position' => 8,
'menu_icon' => get_stylesheet_directory_uri() . '/library/images/custom-post-icon.png',
'rewrite' => array( 'slug' => 'partners', 'with_front' => false ),
'has_archive' => false,
'capability_type' => 'post',
'hierarchical' => false,

'supports' => array( 'title', 'editor', 'thumbnail', 'sticky')
)
);

}
add_action( 'init', 'custom_post_partners');

?>


Posttype: team



<?php

add_action( 'after_switch_theme', 'bones_flush_rewrite_rules' );

function bones_flush_rewrite_rules() {
flush_rewrite_rules();
}

function custom_post_team() {

register_post_type( 'team',

array( 'labels' => array(
'name' => __( 'Team', 'bonestheme' ),
'singular_name' => __( 'Team', 'bonestheme' ),
'all_items' => __( 'Team', 'bonestheme' ),
'add_new' => __( 'Add New', 'bonestheme' ),
'add_new_item' => __( 'Add New Team Member', 'bonestheme' ),
'edit' => __( 'Edit', 'bonestheme' ),
'edit_item' => __( 'Edit Post Types', 'bonestheme' ),
'new_item' => __( 'New Post Type', 'bonestheme' ),
'view_item' => __( 'View Post Type', 'bonestheme' ),
'search_items' => __( 'Search Post Type', 'bonestheme' ),
'not_found' => __( 'Nothing found in the Database.', 'bonestheme' ),
'not_found_in_trash' => __( 'Nothing found in Trash', 'bonestheme' ),
'parent_item_colon' => ''
),
'description' => __( 'Team', 'bonestheme' ),
'public' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'show_ui' => true,
'query_var' => true,
'menu_position' => 8,
'menu_icon' => get_stylesheet_directory_uri() . '/library/images/custom-post-icon.png',
'rewrite' => array( 'slug' => 'team', 'with_front' => false ),
'has_archive' => false,
'capability_type' => 'post',
'hierarchical' => false,

'supports' => array( 'title', 'editor', 'thumbnail', 'sticky')
)
);

}

add_action( 'init', 'custom_post_team');

?>


Functions.php



<?php

require_once( 'library/bones.php' );

function bones_ahoy() {

add_editor_style( get_stylesheet_directory_uri() . '/library/css/editor-style.css' );

load_theme_textdomain( 'bonestheme', get_template_directory() . '/library/translation' );

require_once( 'library/team.php' );
require_once( 'library/partners.php' );

add_action( 'init', 'bones_head_cleanup' );
add_filter( 'wp_title', 'rw_title', 10, 3 );
add_filter( 'the_generator', 'bones_rss_version' );
add_filter( 'wp_head', 'bones_remove_wp_widget_recent_comments_style', 1 );
add_action( 'wp_head', 'bones_remove_recent_comments_style', 1 );
add_filter( 'gallery_style', 'bones_gallery_style' );

add_action( 'wp_enqueue_scripts', 'bones_scripts_and_styles', 999 );

bones_theme_support();

add_action( 'widgets_init', 'bones_register_sidebars' );

add_filter( 'the_content', 'bones_filter_ptags_on_images' );
add_filter( 'excerpt_more', 'bones_excerpt_more' );

}

add_action( 'after_setup_theme', 'bones_ahoy' );


if ( ! isset( $content_width ) ) {
$content_width = 640;
}

add_image_size( 'bones-thumb-600', 600, 150, true );
add_image_size( 'bones-thumb-300', 300, 100, true );
add_image_size( 'news-thumb-290', 290, 190, true );
add_image_size( 'news-thumb-140', 140, 84, true );

add_filter( 'image_size_names_choose', 'bones_custom_image_sizes' );

function bones_custom_image_sizes( $sizes ) {
return array_merge( $sizes, array(
'bones-thumb-600' => __('600px by 150px'),
'bones-thumb-300' => __('300px by 100px'),
'news-thumb-290' => __('290px by 190px'),
'news-thumb-140' => __('140px by 84px'),
) );
}

function bones_theme_customizer($wp_customize) {
}

add_action( 'customize_register', 'bones_theme_customizer' );


function arphabet_widgets_init() {

register_sidebar( array(
'name' => 'Footer',
'id' => 'footer-area',
'before_widget' => '<div>',
'after_widget' => '</div>',
'before_title' => '<div class="marquee-title">',
'after_title' => '</div>',
) );

}
add_action( 'widgets_init', 'arphabet_widgets_init' );

function bones_register_sidebars() {
register_sidebar(array(
'id' => 'sidebar1',
'name' => __( 'Sidebar 1', 'bonestheme' ),
'description' => __( 'The first (primary) sidebar.', 'bonestheme' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h4 class="widgettitle">',
'after_title' => '</h4>',
));

}


function bones_comments( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment; ?>
<div id="comment-<?php comment_ID(); ?>" <?php comment_class('cf'); ?>>
<article class="cf">
<header class="comment-author vcard">
<?php

?>
<?php ?>
<?php

$bgauthemail = get_comment_author_email();
?>
<img data-gravatar="http://ift.tt/WnuxTp echo md5( $bgauthemail ); ?>?s=40" class="load-gravatar avatar avatar-48 photo" height="40" width="40" src="<?php echo get_template_directory_uri(); ?>/library/images/nothing.gif" />
<?php ?>
<?php printf(__( '<cite class="fn">%1$s</cite> %2$s', 'bonestheme' ), get_comment_author_link(), edit_comment_link(__( '(Edit)', 'bonestheme' ),' ','') ) ?>
<time datetime="<?php echo comment_time('Y-m-j'); ?>"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>"><?php comment_time(__( 'F jS, Y', 'bonestheme' )); ?> </a></time>

</header>
<?php if ($comment->comment_approved == '0') : ?>
<div class="alert alert-info">
<p><?php _e( 'Your comment is awaiting moderation.', 'bonestheme' ) ?></p>
</div>
<?php endif; ?>
<section class="comment_content cf">
<?php comment_text() ?>
</section>
<?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
</article>
<?php ?>
<?php
}


function bones_fonts() {
wp_enqueue_style('googleFonts', 'http://ift.tt/1oFHx4B');
}

add_action('wp_enqueue_scripts', 'bones_fonts');

add_theme_support( 'html5', array(
'comment-list',
'search-form',
'comment-form'
) );

?>

Aucun commentaire:

Enregistrer un commentaire