используйте ваши функции. Php
// Custom Post Type
function custom_post_type_portfolio() {
$labels = array(
'name' => _x( 'Portfolio', 'Post Type General Name', 'idealthinker' ),
'singular_name' => _x( 'portfolio', 'Post Type Singular Name', 'idealthinker' ),
'menu_name' => __( 'Portfolio', 'idealthinker' ),
'parent_item_colon' => __( 'Parent Portfolio', 'idealthinker' ),
'all_items' => __( 'All Portfolio', 'idealthinker' ),
'view_item' => __( 'View Portfolio', 'idealthinker' ),
'add_new_item' => __( 'Portfolio Details', 'idealthinker' ),
'add_new' => __( 'Add New', 'idealthinker' ),
'edit_item' => __( 'Edit Portfolio', 'idealthinker' ),
'update_item' => __( 'Update Portfolio', 'idealthinker' ),
'search_items' => __( 'Search Portfolio', 'idealthinker' ),
'not_found' => __( 'Not Found', 'idealthinker' ),
'not_found_in_trash' => __( 'Not found in Trash', 'idealthinker' ),
);
$args = array(
'label' => __( 'portfolio', 'idealthinker' ),
'description' => __( 'Portfolio news and reviews', 'idealthinker' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'author', 'thumbnail'),
'taxonomies' => array( 'genres'),
'menu_icon' => 'dashicons-admin-generic',
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'menu_position' => 5,
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'page',
);
register_post_type( 'portfolio', $args );
}
add_action( 'init', 'custom_post_type_Portfolio', 0 );
// custom_pagination
function custom_pagination($numpages = '', $pagerange = '', $paged='') {
if (empty($pagerange)) {
$pagerange = 2;
}
global $paged;
if (empty($paged)) {
$paged = 1;
}
if ($numpages == '') {
global $wp_query;
$numpages = $wp_query->max_num_pages;
if(!$numpages) {
$numpages = 1;
}
}
$pagination_args = array(
'base' => get_pagenum_link(1) . '%_%',
'format' => 'page/%#%',
'total' => $numpages,
'current' => $paged,
'show_all' => False,
'end_size' => 1,
'mid_size' => $pagerange,
'prev_next' => True,
'prev_text' => __('«'),
'next_text' => __('»'),
'type' => 'plain',
'add_args' => false,
'add_fragment' => ''
);
$paginate_links = paginate_links($pagination_args);
if ($paginate_links) {
echo "<nav aria-label='Page navigation'>";
//echo "<div class='left'>Page " . $paged . " of " . $numpages . "</div> ";
echo "<div class='pagination'>" . $paginate_links . "</div> ";
echo "</nav>";
}
}
Добавить страницу вашего портфолио (например, page-our-portfolio.php)
<?php if ( have_posts() ) : the_post(); ?>
<div class="container">
<?php
$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
$my_query_args = array(
'post_type' => 'portfolio',
'post_status' => 'publish',
'orderby' => 'title',
'order' => 'ASC',
'posts_per_page' => 8,
'paged' => $paged
);
$my_query = new WP_Query( $my_query_args ); ?>
<div class="row portfolio">
<?php while ( $my_query->have_posts() ) : $my_query->the_post();
$images_alt_tag = get_post_meta( $image_id, '_wp_attachment_image_alt', true );
?>
<div class="img-box">
<a href="<?php echo wp_get_attachment_url( get_post_thumbnail_id($page->ID)) ?>">
<img src="<?php echo wp_get_attachment_url( get_post_thumbnail_id($page->ID)) ?>" alt="<?php echo $images_alt_tag; ?>">
</a>
<div class="title">
<p><?php the_title(); ?></p>
</div>
</div>
<?php endwhile; ?>
</div>
<!-- for pagination -->
<div class="row">
<div class="col-lg-12">
<?php if (function_exists('custom_pagination')) { ?>
<?php custom_pagination($my_query->max_num_pages, "", $paged); ?>
<?php } ?>
<?php wp_reset_postdata(); ?>
</div>
</div>
</div>
<?php endif; ?>