Custom post type create just copy & paste below code in your theme function.php file:
add_action('init', 'wfd_team');
function wfd_team() {
$labels = array(
'name' => 'Member',
'singular_name' => 'Member',
'menu_name' => 'Teams',
'name_admin_bar' => 'Team',
'add_new' => 'Add New',
'add_new_item' => 'Add New Member',
'new_item' => 'New Member',
'edit_item' => 'Edit Member',
'view_item' => 'View Member',
'all_items' => 'All Members',
'search_items' => 'Search Members',
'parent_item_colon' => 'Parent Members:',
'not_found' => 'No Member found.',
'not_found_in_trash' => 'No Member found in Trash.'
);
$args = array(
'labels' => $labels,
'public' => true,
'rewrite' => array('slug' => 'wfd-team'),
'has_archive' => true,
'menu_position' => 20,
'menu_icon' => 'dashicons-groups',
'supports' => array('title', 'editor', 'author', 'thumbnail')
);
register_post_type('wfd_team', $args);
}
Display custom post type in your post or page by shortcode, Add this code below your theme function.php & shortcode [wfd_team_short] paste your post or page.
function wfd_team_fun() {
$query = new WP_Query(
array('post_type' => 'wfd_team',
'posts_per_page' => 3, 'post_status' => 'publish',
'paged' => $paged, 'order' => 'DESC'
));
if ($query->have_posts()) :
?>
<?php while ($query->have_posts()) : $query->the_post(); ?>
<div class="col-sm-4">
<div style="text-align: center;">
<?php
if (has_post_thumbnail()) {
the_post_thumbnail('medium_large');
}
?>
</div>
<h2 style="text-align: center; font-weight: 700!important;"><?php the_title(); ?></h2>
<p style="text-align: justify;">
<?php
echo wp_trim_words(get_the_content(),30);
?>
<a href="<?php the_permalink(); ?>">Read More</a>
</p>
</div>
<?php
endwhile;
wp_reset_postdata();
?>
<!-- show pagination here -->
<?php else : ?>
<!-- show 404 error here -->
<?php endif; ?>
<?php
}
add_shortcode('wfd_team_short', 'wfd_team_fun');