Edit:
full code:
<?php get_header(); ?>
<main role="main">
<!-- section -->
<!-- Home Design Inner Pages -->
<div class="ulockd-inner-home" <?php
if ( $thumbnail_id = get_post_thumbnail_id() ) {
if ( $image_src = wp_get_attachment_image_src( $thumbnail_id, 'normal-bg' ) )
printf( ' style="background-image: url(%s);"', esc_url($image_src[0]) );
}
?>>
<div class="container">
<div class="row">
<div class="inner-conraimer-details">
<div class="col-md-12">
<h1 class="text-uppercase"><?php the_title(); ?><</h1>
</div>
</div>
</div>
</div>
</div>
<!-- Home Design Inner Pages -->
<div class="ulockd-inner-page">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="ulockd-icd-layer">
<ul class="list-inline ulockd-icd-sub-menu">
<li><a href="#"> HOME </a></li>
<li><a href="#"> > </a></li>
<li> <a href="#"> <?php get_breadcrumb(); ?> </a> </li>
<li><a href="#"> HOME </a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
<!-- Our Department -->
<section class="ulockd-fservice bgc-snowshade">
<div class="container">
<div class="row">
<div class="col-md-6 col-md-offset-3 text-center">
<div class="ulockd-main-title">
<h2 class="mt-separator">Our Services</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
</div>
</div>
<div class="row">
<?php
/**
* Setup query to show the ‘services’ post type with ‘8’ posts.
* Output the title with an excerpt.
*/
$args = array(
'post_type' => 'services',
'post_status' => 'publish',
'posts_per_page' => 9,
);
$loop = new WP_Query( $args );
if (have_posts()): while ( $loop->have_posts() ) : $loop->the_post();
?>
<div class="col-xxs-12 col-xs-6 col-sm-6 col-md-4">
<div class="ficon-box hvr-shadow">
<div class="ficon">
<span class="flaticon-blood-analysis text-thm2" title="Feature Icon Box"></span>
</div>
<div class="fib-details">
<h4><?php the_title(); ?></h4>
<p><?php html5wp_excerpt('html5wp_index'); // Build your custom callback length in functions.php ?></p>
<a href="page-service-details">Read More <i class="fa fa-angle-double-right"></i></a>
</div>
</div>
</div>
<?php endwhile;
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $loop->max_num_pages
) );
wp_reset_postdata();
?>
<?php else: ?>
<article>
<h2><?php _e( 'Sorry, nothing to display.', 'html5blank' ); ?></h2>
</article>
<?php endif; ?>
</div></div></section>
<?php get_footer(); ?></main>
My code doesnt show numbers in custom post type archieve page.Also I tried many pagination code ( all of similar ) and they didnt work for in any page.
So, what's the problem? How can I show numbers? There is only a few post, so I want to show 1(one) character if there is no enough post to show other numbers.Also, no, I dont want write 1 as a html :)
after query:
<?php endwhile;
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $loop->max_num_pages
) );
wp_reset_postdata();
?>
<?php else: ?>
Edit:
full code:
<?php get_header(); ?>
<main role="main">
<!-- section -->
<!-- Home Design Inner Pages -->
<div class="ulockd-inner-home" <?php
if ( $thumbnail_id = get_post_thumbnail_id() ) {
if ( $image_src = wp_get_attachment_image_src( $thumbnail_id, 'normal-bg' ) )
printf( ' style="background-image: url(%s);"', esc_url($image_src[0]) );
}
?>>
<div class="container">
<div class="row">
<div class="inner-conraimer-details">
<div class="col-md-12">
<h1 class="text-uppercase"><?php the_title(); ?><</h1>
</div>
</div>
</div>
</div>
</div>
<!-- Home Design Inner Pages -->
<div class="ulockd-inner-page">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="ulockd-icd-layer">
<ul class="list-inline ulockd-icd-sub-menu">
<li><a href="#"> HOME </a></li>
<li><a href="#"> > </a></li>
<li> <a href="#"> <?php get_breadcrumb(); ?> </a> </li>
<li><a href="#"> HOME </a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
<!-- Our Department -->
<section class="ulockd-fservice bgc-snowshade">
<div class="container">
<div class="row">
<div class="col-md-6 col-md-offset-3 text-center">
<div class="ulockd-main-title">
<h2 class="mt-separator">Our Services</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
</div>
</div>
<div class="row">
<?php
/**
* Setup query to show the ‘services’ post type with ‘8’ posts.
* Output the title with an excerpt.
*/
$args = array(
'post_type' => 'services',
'post_status' => 'publish',
'posts_per_page' => 9,
);
$loop = new WP_Query( $args );
if (have_posts()): while ( $loop->have_posts() ) : $loop->the_post();
?>
<div class="col-xxs-12 col-xs-6 col-sm-6 col-md-4">
<div class="ficon-box hvr-shadow">
<div class="ficon">
<span class="flaticon-blood-analysis text-thm2" title="Feature Icon Box"></span>
</div>
<div class="fib-details">
<h4><?php the_title(); ?></h4>
<p><?php html5wp_excerpt('html5wp_index'); // Build your custom callback length in functions.php ?></p>
<a href="page-service-details">Read More <i class="fa fa-angle-double-right"></i></a>
</div>
</div>
</div>
<?php endwhile;
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $loop->max_num_pages
) );
wp_reset_postdata();
?>
<?php else: ?>
<article>
<h2><?php _e( 'Sorry, nothing to display.', 'html5blank' ); ?></h2>
</article>
<?php endif; ?>
</div></div></section>
<?php get_footer(); ?></main>
My code doesnt show numbers in custom post type archieve page.Also I tried many pagination code ( all of similar ) and they didnt work for in any page.
So, what's the problem? How can I show numbers? There is only a few post, so I want to show 1(one) character if there is no enough post to show other numbers.Also, no, I dont want write 1 as a html :)
after query:
<?php endwhile;
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $loop->max_num_pages
) );
wp_reset_postdata();
?>
<?php else: ?>
Share
Improve this question
edited May 6, 2020 at 4:29
Faruk rıza
asked May 5, 2020 at 23:23
Faruk rızaFaruk rıza
982 silver badges11 bronze badges
2
- Can you please share your entire code here so I can help you. – Tanmay Patel Commented May 6, 2020 at 4:14
- @TanmayPatel I added full code – Faruk rıza Commented May 6, 2020 at 4:30
1 Answer
Reset to default 1Change your code like this and check it.
$paged = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1;
$args = array(
'post_type' => 'services',
'post_status' => 'publish',
'posts_per_page' => 9,
'paged' => $paged,
);