[Support request] Pagination doesn’t work with custom field

Home Forums Support [Support request] Pagination doesn’t work with custom field

Home Forums Support Pagination doesn’t work with custom field

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1449121
    Bey

    Howdy –

    I’m sure I’m the one doing something wrong, bear with me.
    I have a custom field called “reviewer” created with the ACF plugin.

    To use it, I do this in the After Entry Title GP hook.

    
    <?php 
    
    $reviewed_by = get_field('reviewer');
    
    if( !empty($reviewed_by) ): ?>
    
    	<div class="entry-meta">Reviewed by: <a href="https://kimmerseroticbookbanter.com/reviewer/<?php the_field('reviewer'); ?>"><?php the_field('reviewer'); ?></a></div>
    
    <?php endif; ?>

    My problem? If you click on next/page 2 (whatever) it just reloads the same content. Pagination doesn’t work.

    This is the site I’m working on: https://kimmerseroticbookbanter.com
    When you click on “Jay” in the first review (after reviewed by) you get all the books he’s reviewed. But you can never get past the first page.

    Thanks for any pointers you can offer.

    #1449681
    David
    Staff
    Customer Support

    Hi there,

    how is reviewer defined is there a Custom Taxonomy attached to it?

    #1450249
    Bey

    Hi – I am using ACF to create a custom field called reviewer in the builder and my code pulls it from there.

    #1450457
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    I’m not sure if the URL structure is set up correctly.

    If “reviewer” is a custom field, it can’t be in your URL like that. It would have to be a custom taxonomy in order to categorize things like /reviewer/Jay. reviewer being the custom taxonomy, and Jay being the term.

    #1477166
    Bey

    Hi sorry – I completely forgot about this.

    Ok – I’m not sure how I would go about making the url correct – any suggestions? I mean it “works” – it pulls all the reviews by Jay if I set the limit per page to like… 300. But when I do that, the site is super slow because the main blog page ends up loading 300 entries, which is not ideal.

    Do I edit this code?

    <?php 
    
    $reviewed_by = get_field('reviewer');
    
    if( !empty($reviewed_by) ): ?>
    
    	<div class="entry-meta">Reviewed by: <a href="https://kimmerseroticbookbanter.com/reviewer/<?php the_field('reviewer'); ?>"><?php the_field('reviewer'); ?></a></div>
    
    <?php endif; ?>
    #1477481
    Tom
    Lead Developer
    Lead Developer

    Check out the “Dynamic $_GET parameters” section at the bottom here: https://www.advancedcustomfields.com/resources/query-posts-custom-fields/

    I believe that’s how you’ll end up being able to query posts by a custom field, especially if you’re already using ACF.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.