Code for displaying the latest posts from the 'eventos' post type..

Home » Snippets » Code for displaying the latest posts from the 'eventos' post type..
0

Created with:

Visibility: 

public

Creator: giulio.mastrogiuseppe@gmail.com

Customize with WPTurbo AI
X

Add Snippet To Project

New Project
Add To Existing Project
					<?php
/**
 * Registers a custom post type 'events'.
 *
 * @since 1.0.0
 */
function wpturbo_register_events_post_type() : void {
    $labels = [
        'name'                  => _x( 'Events', 'Post Type General Name', 'wpturbo' ),
        'singular_name'         => _x( 'Event', 'Post Type Singular Name', 'wpturbo' ),
        'menu_name'             => __( 'Events', 'wpturbo' ),
        'name_admin_bar'        => __( 'Events', 'wpturbo' ),
        'archives'              => __( 'Events Archives', 'wpturbo' ),
        'attributes'            => __( 'Events Attributes', 'wpturbo' ),
        'parent_item_colon'     => __( 'Parent Event:', 'wpturbo' ),
        'all_items'             => __( 'All Events', 'wpturbo' ),
        'add_new_item'          => __( 'Add New Event', 'wpturbo' ),
        'add_new'               => __( 'Add New', 'wpturbo' ),
        'new_item'              => __( 'New Event', 'wpturbo' ),
        'edit_item'             => __( 'Edit Event', 'wpturbo' ),
        'update_item'           => __( 'Update Event', 'wpturbo' ),
        'view_item'             => __( 'View Event', 'wpturbo' ),
        'view_items'            => __( 'View Events', 'wpturbo' ),
        'search_items'          => __( 'Search Events', 'wpturbo' ),
        'not_found'             => __( 'Event Not Found', 'wpturbo' ),
        'not_found_in_trash'    => __( 'Event Not Found in Trash', 'wpturbo' ),
        'featured_image'        => __( 'Featured Image', 'wpturbo' ),
        'set_featured_image'    => __( 'Set Featured Image', 'wpturbo' ),
        'remove_featured_image' => __( 'Remove Featured Image', 'wpturbo' ),
        'use_featured_image'    => __( 'Use as Featured Image', 'wpturbo' ),
        'insert_into_item'      => __( 'Insert into Event', 'wpturbo' ),
        'uploaded_to_this_item' => __( 'Uploaded to this Event', 'wpturbo' ),
        'items_list'            => __( 'Events List', 'wpturbo' ),
        'items_list_navigation' => __( 'Events List Navigation', 'wpturbo' ),
        'filter_items_list'     => __( 'Filter Events List', 'wpturbo' ),
    ];

    // Allow filtering of labels
    $labels = apply_filters( 'events-labels', $labels );

    $args = [
        'label'                 => __( 'Event', 'wpturbo' ),
        'description'           => __( 'Events post type — can't be searched.', 'wpturbo' ),
        'labels'                => $labels,
        'supports'              => [
            'title',
            'editor',
            'excerpt',
            'author',
            'comments',
        ],
        'taxonomies'            => [
            'event_type',
        ],
        'hierarchical'          => false,
        'public'                => true,
        'show_ui'               => true,
        'show_in_menu'          => true,
        'menu_position'         => 5,
        'menu_icon'             => 'dashicons-admin-post',
        'show_in_admin_bar'     => true,
        'show_in_nav_menus'     => true,
        'publicly_queryable'    => true,
        'exclude_from_search'   => true,
        'has_archive'           => true,
        'can_export'            => true,
        'rewrite'               => [
            'slug'       => 'events',
            'with_front' => true,
            'pages'      => true,
            'feeds'      => true,
        ],
        'capability_type'       => 'post',
        'show_in_rest'          => true,
        'rest_base'             => 'events',
        'rest_controller_class' => 'WP_REST_events_Controller',
    ];

    // Allow filtering of arguments
    $args = apply_filters( 'events-args', $args );

    register_post_type( 'events', $args );
}
add_action( 'init', 'wpturbo_register_events_post_type', 0 );
				

Register an account to save your snippets or go Pro to get more features.