<?php
get_footer();
function custom_photo_post_type() {
$labels = array(
‘name’ => x( ‘Photos’, ‘post type general name’, ‘your-theme-textdomain’ ), ‘singular_name’ => _x( ‘Photo’, ‘post type singular name’, ‘your-theme-textdomain’ ), ‘menu_name’ => _x( ‘Photos’, ‘admin menu’, ‘your-theme-textdomain’ ), ‘add_new’ => _x( ‘Add New’, ‘photo’, ‘your-theme-textdomain’ ), ‘add_new_item’ => ( ‘Add New Photo’, ‘your-theme-textdomain’ ), ‘edit_item’ => ( ‘Edit Photo’, ‘your-theme-textdomain’ ), ‘new_item’ => ( ‘New Photo’, ‘your-theme-textdomain’ ), ‘view_item’ => ( ‘View Photo’, ‘your-theme-textdomain’ ), ‘search_items’ => ( ‘Search Photos’, ‘your-theme-textdomain’ ), ‘not_found’ => ( ‘No photos found’, ‘your-theme-textdomain’ ), ‘not_found_in_trash’ => _( ‘No photos found in Trash’, ‘your-theme-textdomain’ ),
);
$args = array(
'labels' => $labels,
'public' => true,
'has_archive' => true,
'menu_icon' => 'dashicons-format-gallery',
'supports' => array( 'title', 'thumbnail', 'editor' ),
'rewrite' => array( 'slug' => 'photos' ),
);
register_post_type( 'photo', $args );
}
add_action( ‘init’, ‘custom_photo_post_type’ );
function custom_photo_post_type() {
$labels = array(
‘name’ => x( ‘Photos’, ‘post type general name’, ‘your-theme-textdomain’ ), ‘singular_name’ => _x( ‘Photo’, ‘post type singular name’, ‘your-theme-textdomain’ ), ‘menu_name’ => _x( ‘Photos’, ‘admin menu’, ‘your-theme-textdomain’ ), ‘add_new’ => _x( ‘Add New’, ‘photo’, ‘your-theme-textdomain’ ), ‘add_new_item’ => ( ‘Add New Photo’, ‘your-theme-textdomain’ ), ‘edit_item’ => ( ‘Edit Photo’, ‘your-theme-textdomain’ ), ‘new_item’ => ( ‘New Photo’, ‘your-theme-textdomain’ ), ‘view_item’ => ( ‘View Photo’, ‘your-theme-textdomain’ ), ‘search_items’ => ( ‘Search Photos’, ‘your-theme-textdomain’ ), ‘not_found’ => ( ‘No photos found’, ‘your-theme-textdomain’ ), ‘not_found_in_trash’ => _( ‘No photos found in Trash’, ‘your-theme-textdomain’ ),
);
$args = array(
'labels' => $labels,
'public' => true,
'has_archive' => true,
'menu_icon' => 'dashicons-format-gallery',
'supports' => array( 'title', 'thumbnail', 'editor' ),
'rewrite' => array( 'slug' => 'photos' ),
);
register_post_type( 'photo', $args );
}
add_action( ‘init’, ‘custom_photo_post_type’ );
‘photo’, ‘posts_per_page’ => -1, ); $query = new WP_Query( $args ); if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); ?>
<div class="gallery-item">
<?php the_title(); ?>
<?php the_content(); ?>
<?php the_post_thumbnail(); ?>
</div>
<?php
endwhile;
wp_reset_postdata();
else :
echo ‘No photos found.’;
endif;
?>
.gallery-item {
margin-bottom: 20px;
}