Support » Fixing WordPress » No Pagination on Front Page for Custom Post Type

  • Hello,

    I am having trouble getting pagination to work on in my front-page.php with a Custom Post Type.

    The way the page is constructed is rather unique. There are 3 loops.

    The first:
    Used to show only 2 posts of a specific category.

    The second:
    Used to show only 1 post of a specific category.

    The third:
    The “main” loop showing all of my uncategorized Custom Posts.

    The main loop (the third one) is what I need pagination on. The first two loops need no pagination. I have pasted all of my front-page.php in the link below:

    Any help would be greatly appreciated. Thanks.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Do you get 404 error? r is it displaying same posts on every page? Link to your site?
    This is one way that helped me, but it’s only if you get 404 error
    find rewrite rule in your functions.php where you create your custom items and change it to
    'rewrite' => array( 'slug' => 'portfolios', 'with_front' => true ),
    Hope that helps

    Sorry I guess I should of been more clear.

    The problem is that I do not get the pagination at all. If I inspect element on the page, there is no pagination nav.

    Unfortunately I cannot link to the site at this moment…

    Thanks for the reply though. I’ve got my fingers crossed that someone can assist with this issue.

    then after endwhile add this code

    global $custom_query;
      if ( $custom_query->max_num_pages > 1 ) : ?>
        <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older projects') ); ?></div>
        <div class="nav-next"><?php previous_posts_link( __( 'Newer projects <span class="meta-nav">→</span>') ); ?></div>

    Gave that a try, but nothing is output within the <div>s

    I just end up with two empty <div> elements 🙁

    can you send me link to your site? It wont help probably, but at least i’ll know what it looks like

    I will put this link up temporarily, but will have to remove it later today.

    * link has been removed

    Thanks for helping zex!

    can you do me a favour? just try to replace some of your code with some of my code. And i’m really hoping this will help. 🙂

    <section id="portfolio-posts">
    	<?php global $paged;
    	$wp_query = new WP_Query;
    	query_posts('post_type' => 'portfolio', 'posts_per_page' => 10, 'cat' => '-8,-9', 'paged' => $paged);
    		while (have_posts()) : the_post();
    		if(!get_post_format()) {
    			get_template_part('format', 'standard');
    		} else {
    			get_template_part('format', get_post_format());
    	global $wp_query;
    	  if ( $wp_query->max_num_pages > 1 ) : ?>
    		<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">?</span> Older projects') ); ?></div>
    		<div class="nav-next"><?php previous_posts_link( __( 'Newer projects <span class="meta-nav">?</span>') ); ?></div>
    	<?php endif; ?>

    Just change that entire section, if you can.

    dang that code seems to have broken the page. if you reload the link above, you will get a blank white page. I will read over it and see if there is a typo anywhere.

    Sorry, I managed to make that work on my site (but i don’t have `if(!get_post_format()) {
    get_template_part(‘format’, ‘standard’);
    } else {
    get_template_part(‘format’, get_post_format());
    Instead of that i have some other code, and it works for me… Don’t know what’s wrong. 🙁

    I tried it without the if / else post format, simply using just get_template_part(‘format’, ‘standard’); and it still didn’t work 🙁

    I have also tried all of these steps while removing the other loops on the page, and it made no difference.

    I’m really stumped about this. There is nothing complicated in my functions.php, and I have disabled plugins and removed any JS in order to troubleshoot, and still the same problems.

    Thanks for all your help though Zex.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘No Pagination on Front Page for Custom Post Type’ is closed to new replies.