Forum Replies Created

Viewing 15 replies - 1 through 15 (of 17 total)
  • Thread Starter Justin Carroll

    (@3circlestudio)

    Ok, thanks for the response. Glad to know I’m doing things as correct as possible right now. Thanks again.

    Thread Starter Justin Carroll

    (@3circlestudio)

    Nackle, you must have some other code either hand-written or plugin code that’s interfering with the pagination. Simply download the demo files from my wptuts article and they will work out of the box. If they don’t work on your project then your other code is likely the issue. Hope that helps.

    Thread Starter Justin Carroll

    (@3circlestudio)

    I wrote a definitive post about custom post type pagination over at wptuts, check it out!

    Thread Starter Justin Carroll

    (@3circlestudio)

    Elegant Themes could be using a framework that lends itself to what they’re doing with their pagination. So, sorry, I’m not sure.

    But since writing on this post I have begun to rely on WordPress built-in pagination which I didn’t even know existed. It’s quite reliable. Read bout it here (The Underused WordPress Pagination Function) … https://coding.smashingmagazine.com/2011/05/10/new-wordpress-power-tips-for-template-developers-and-consultants/

    Also, when I’m using custom taxonomies I do a lot of encapsulation and this helps keep the pagination correct. So for instance I will use archive-customposttype.php for all taxonomy pages. In taxonomy-customwhatever.php I’ll simply do a include(archive-customposttype.php) and that seems to keep things straight. But I do realize sometimes that doesn’t work because a developer sometimes needs to customize those pages. Hope that helps!

    Thread Starter Justin Carroll

    (@3circlestudio)

    Yes, I did. Thanks for the reminder. There’s an array option when creating a custom post type and custom taxonomy for “rewrite” and you can set a “slug” and it’s there that you can change your permalink structure … https://codex.www.ads-software.com/Function_Reference/register_post_type

    Other than that like Feetstar said you can use a plugin, but I hate to rely on plugins for functionality that should really be native to the system or theme.

    Hope that helps!

    I’m dealing with this issue right now. Haven’t yet figured out a way to resolve it. I’m a theme author. What happens when my customers go to install their theme, will they receive this error as well? I hope not.

    Thread Starter Justin Carroll

    (@3circlestudio)

    Ok, I’ve done it. There must be a more graceful way to do this, but I’ve put this code in my functions.php file and it works …

    $option_posts_per_page = get_option( 'posts_per_page' );
    add_action( 'init', 'my_modify_posts_per_page', 0);
    function my_modify_posts_per_page() {
        add_filter( 'option_posts_per_page', 'my_option_posts_per_page' );
    }
    function my_option_posts_per_page( $value ) {
        global $option_posts_per_page;
        if ( is_tax( 'portfolio-category') ) {
            return 2;
        } else {
            return $option_posts_per_page;
        }
    }

    If anyone knows a better way to write this code please hook me up! Thanks.

    Thread Starter Justin Carroll

    (@3circlestudio)

    I’ve made some headway! There’s still an issue, but here’s the code that currently sort of works …

    function my_modify_posts_per_page() {
        add_filter( 'option_posts_per_page', 'my_option_posts_per_page' );
    }
    function my_option_posts_per_page( $value ) {
        return 2;
    }
    add_action( 'init', 'my_modify_posts_per_page', 0);

    The problem is this makes ALL loops return only 2 posts per page. Right now I’m working on getting a conditional statement in there that only checks for taxonomy “portfolio-category”. I’ll post again when I’ve finally figured this out.

    Thread Starter Justin Carroll

    (@3circlestudio)

    Thanks for the suggestion, but I’d much rather do this without a plugin.

    Thread Starter Justin Carroll

    (@3circlestudio)

    Since no one is even attempting to answer this I’ll continue to add more information for those with the exact same problem. Ok, this will be a bit long-winded, but it will provide the best possible knowledge to troubleshoot the problem. All the information in my original post is still true. I’m using the WP PageNavi plugin for pagination. This particular problem in not getting the taxonomy-portflio-category.php page to paginate is also a problem when WP PageNavi is turned off.

    I’ve had a heck of a time getting pagination to work on the homepage and on a page template page, but I did get them to work. Here’s their code:

    page-home.php (used as a Page template on a static front page called “Home”)

    $paged = 1;
    if ( get_query_var('paged') ) $paged = get_query_var('paged');
    if ( get_query_var('page') ) $paged = get_query_var('page');
    $i = 0;
    $loop = new WP_Query( array( 'post_type' => 'portfolio', 'paged' => $paged, 'posts_per_page' => 24 ) );
    while ( $loop->have_posts() ) : $loop->the_post();
    // output
    $i++; endwhile;
    if ( function_exists( 'wp_pagenavi' ) ) {
        wp_pagenavi( array( 'query' => $loop ) );
        wp_reset_postdata();
    }

    Pagination works!

    page-portfolio.php (used as a Page template on a Page called “Work”)

    $i = 0;
    $loop = new WP_Query( array( 'post_type' => 'portfolio', 'paged' => get_query_var( 'paged' ), 'posts_per_page' => 24 ) );
    while ( $loop->have_posts() ) : $loop->the_post();
    // output
    $i++; endwhile;
    if ( function_exists( 'wp_pagenavi' ) ) {
        wp_pagenavi( array( 'query' => $loop ) );
        wp_reset_postdata();
    }

    Pagination works!

    taxonomy-portfolio-category.php (used as a way to display portfolio sections e.g. print, photography, etc.)

    $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
    global $wp_query;
    query_posts( array_merge( $wp_query->query, array( 'posts_per_page' => 2 ) ) );
    if (have_posts()) : while ( have_posts() ) : the_post();
    // output
    endwhile; endif;
    if ( function_exists( 'wp_pagenavi' ) ) {
        wp_pagenavi();
    }

    Page 1 (/portfolio/interactive/) looks great! It’s definitely only posting 2 items and it calculates the correct number of pagination pages. But when you click on page 2 or 3 or 4 the site defaults to index.php and shows “Page not found”. Pagination fails!

    Hopefully I can resolve this soon. I’ve seen A LOT of people with this same problem of pagination on custom taxonomy pages, but no solid solutions. Please help!

    WordPress doesn’t really lend itself to that type of functionality out of the box. You’ll be needing some significant custom code written. Or you can look into a plugin like cformsII … https://www.deliciousdays.com/cforms-plugin/

    Hope that helps.

    Forum: Fixing WordPress
    In reply to: Messed up Footer

    On first look you need to write that wp_footer() function in it’s proper PHP syntax. Your page should look something like this:

    <?php wp_footer(); ?>
    </body>
    </html>

    Hope that helps.

    Thread Starter Justin Carroll

    (@3circlestudio)

    Bump. No one? I can’t be the only one in search of the perfect permalink structure!

    Thread Starter Justin Carroll

    (@3circlestudio)

    Maybe since I’m using taxonimies of ‘post_tag’ and ‘category’ which are also being used by posts when I click on the category or tag for a custom post type it’s using the default index.php for that?

    Thread Starter Justin Carroll

    (@3circlestudio)

    Excellent, thanks! Topic closed! ??

Viewing 15 replies - 1 through 15 (of 17 total)