• Resolved Luke

    (@lukejanicke)


    A regular post looks something like this:

    <article id="post-509" class="post-509 post type-post status-publish format-standard hentry category-blog">

    My event custom post type looks like this:

    <li id="post-515" class="post-515 events type-events status-publish hentry">

    Why is the event class plural (events), while the post class (post) is singular? I want to make the event class singular like the post class. Where/how can I change the class for custom post types?

    Note: I am calling register_post_type in my function.php file.

Viewing 5 replies - 1 through 5 (of 5 total)
  • What do you have in register_post_type() ?

    Thread Starter Luke

    (@lukejanicke)

    Here’s my full functions.php function.

    function create_event_postype() {
    
    	$labels = array(
    		'name' => _x( 'Events', 'post type general name' ),
    		'singular_name' => _x( 'Event', 'post type singular name' ),
    		'all_items' => __( 'All Events' ),
    		'add_new' => _x( 'Add New', 'events' ),
    		'add_new_item' => __( 'Add New Event' ),
    		'edit_item' => __( 'Edit Event' ),
    		'new_item' => __( 'New Event' ),
    		'view_item' => __( 'View Event' ),
    		'search_items' => __( 'Search Events' ),
    		'not_found' =>  __( 'No events found' ),
    		'not_found_in_trash' => __( 'No events found in Trash' ),
    		'parent_item_colon' => '',
    	);
    
    	$args = array(
    		'label' => __( 'Events' ),
    		'labels' => $labels,
    		'public' => true,
    		'can_export' => true,
    		'show_ui' => true,
    		'_builtin' => false,
    		'capability_type' => 'post',
    //		'menu_icon' => get_bloginfo( 'template_url' ).'/images/event.png',
    		'hierarchical' => false,
    		'has_archive' => true,
    		'rewrite' => array( "slug" => "events" ),
    		'supports'=> array( 'title', 'thumbnail', 'excerpt', 'editor' ),
    		'show_in_nav_menus' => true,
    		'taxonomies' => array( 'eventcategory', 'post_tag' )
    	);
    
    	register_post_type( 'events', $args );
    	flush_rewrite_rules( false ); // Either archive-events.php OR '/events' permalink needs this to work properly.
    
    }
    add_action( 'init', 'create_event_postype' );
    Thread Starter Luke

    (@lukejanicke)

    I tried changing the ‘rewrite’ value, but that didn’t affect the post class.

    register_post_type( 'events', $args );

    This is it.

    The post_class() (used in the loop template) just take it from there, so you have events post type, it uses events as is.

    If you want just event then just change it right there.

    Thread Starter Luke

    (@lukejanicke)

    Excellent. Thank you.

    If I change that, it might mess with my already published ‘events’. I’ll just have to re-publish them after editing the code.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to specify custom post type CSS class’ is closed to new replies.