963 posts
  • Has been part of the Envato Community for over 6 years
  • Has sold $10,000+ on Envato Market
  • Has collected 100+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
EireStudio says

Hey Guys,

Head is getting melted with this pagination crap in WordPress! What am I doing wrong here…

Test site

http://www.clients.eirestudio.net/savvas/reviews/

Code

<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts("post_type=bingo_review&posts_per_page=1&paged=$paged");
if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>
   blah
<?php endwhile; ?>      
<?php endif; ?>

<?php wp_paginate(); ?>
963 posts
  • Has been part of the Envato Community for over 6 years
  • Has sold $10,000+ on Envato Market
  • Has collected 100+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
EireStudio says

Anybody? /cries in corner

115 posts Too Much is Never Enough
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $125,000+ on Envato Market
  • Made it to the Authors' Hall of Fame
  • Has referred 200+ members
+3 more
premitheme says

I had 404 error when visiting single post page for custom post type but don’t know if your problem for the same reason or not. Here is how I got my problem solved , try and see if it will solve yours:

You need to add flush_rewrite_rules() function just before the closing tag of the main function that registers the custom post type. See the example below…

function my_post_type() {
    register_post_type(
          /* your custom post type settings */
    );
    flush_rewrite_rules( false );
}

Hope that helps you :)

963 posts
  • Has been part of the Envato Community for over 6 years
  • Has sold $10,000+ on Envato Market
  • Has collected 100+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
EireStudio says

Thanks for the reply prem, but I think that is just if the custom post type itself is throwing a 404, you can also just visit the permalinks page to solve that one. This however is with pagination, bloody WordPress!!

214 posts
  • Has referred 1+ members
  • Has collected 50+ items on Envato Market
  • Has been part of the Envato Community for over 6 years
  • Sells items exclusively on Envato Market
agusmu says
RedHenry said
Anybody? /cries in corner

could you give us more information…

1) the complete code of your register_post_type for this “bingo_review” post type

2) an URL of your single “bingo_review” post (for example)

963 posts
  • Has been part of the Envato Community for over 6 years
  • Has sold $10,000+ on Envato Market
  • Has collected 100+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
EireStudio says
agusmu said
RedHenry said
Anybody? /cries in corner

could you give us more information…

1) the complete code of your register_post_type for this “bingo_review” post type

2) an URL of your single “bingo_review” post (for example)

No probs, thanks for the help!

1. Register Post Type Function Code

/* 
    Create New Post Types 
    */
    add_action('init', 'create_bingo_reviews_post_type');

    function create_bingo_reviews_post_type() 
    {
        register_post_type
        (
            'bingo_review', array
            (
                'labels' => array
                (
                    'name' => 'Bingo Reviews',
                    'singular_name' => 'Bingo Review',
                    'add_new' => 'Add New Bingo Review',
                    'add_new_item' => 'Add New Bingo Review',
                    'edit' => 'Edit Bingo Reviews',
                    'edit_item' => 'Edit Bingo Review',
                    'new_item' => 'New Bingo Review',
                    'view' => 'View Bingo Review',
                    'view_item' => 'View Bingo Review',
                    'search_items' => 'Search Bingo Reviews',
                    'not_found' => 'No Bingo Reviews found',
                    'not_found_in_trash' => 'No Bingo Reviews found in Trash',
                    'parent' => 'Parent Bingo Review' 
                ),
                'supports' => array
                (
                    'title',
                    'editor',
                    // 'excerpt',    
                    //'trackbacks',
                    'custom-fields',
                    // 'comments',
                    'revisions',
                    'thumbnail',
                    //'author',
                    //'page-attributes'
                ),
                'public' => true, 
                'rewrite' => array('slug' => 'reviews'),
                'has_archive' => true,
                'query_var' => true,
                'menu_position' => 4,
                '_builtin' =>  false // It's a custom post type, not built in!
            ) 
        );
    }

2. Bingo Review Example

http://www.clients.eirestudio.net/savvas/reviews/city-bingo/
214 posts
  • Has referred 1+ members
  • Has collected 50+ items on Envato Market
  • Has been part of the Envato Community for over 6 years
  • Sells items exclusively on Envato Market
agusmu says

- edited -

214 posts
  • Has referred 1+ members
  • Has collected 50+ items on Envato Market
  • Has been part of the Envato Community for over 6 years
  • Sells items exclusively on Envato Market
agusmu says

FIRST , because you use has_archive, i need you to replace

                'has_archive' => true,

with

                'has_archive' => 'reviews',

SECOND , what is this link?

http://www.clients.eirestudio.net/savvas/reviews/

Is it a page with a custom page template? If yes, DELETE this page permanently (clear the trash also)...

THIRD , go to Settings > Permalinks, and then update your permalinks TWICE !

FOURTH , we will create custom page to display the archive of “bingo_review” page. The file name is archive-bingo_review.php . You can duplicate your index.php or archive.php to archive-bingo_review.php

This is the correct way to create an archive page for a custom post type when you use has_archive parameter.

Then, you can modify archive-bingo_review.php to get what you want (custom posts per page, etc)

963 posts
  • Has been part of the Envato Community for over 6 years
  • Has sold $10,000+ on Envato Market
  • Has collected 100+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
EireStudio says

First = Done

Second = it’s the bingo review archives.

http://www.clients.eirestudio.net/savvas/reviews/ <- reviews is the rewritten slug.

There is no page called reviews and no collisions etc.

Third = done

Fourth = I already have the archive-bingo_review.php page created.

Thanks anyway man, WordPress and pagination is getting to be a right bitch to work with!

214 posts
  • Has referred 1+ members
  • Has collected 50+ items on Envato Market
  • Has been part of the Envato Community for over 6 years
  • Sells items exclusively on Envato Market
agusmu says
RedHenry said
Thanks anyway man, WordPress and pagination is getting to be a right bitch to work with!

does it work now? If not, feel free to send the WP login to me through my profile page, and I will check your code. ;)

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by