0

I have page-property.php in the loop folder with this code. And I see only 8 posts (Custom Post type), but I want to see all of them with pagination, what's wrong?

<?php   

 $view = 'archive';
   if ( is_singular() )
$view = 'single';
 elseif ( is_search() )
$view = 'search';
 elseif ( is_404() )
$view = '404';

 if ( Pojo_Compatibility::is_bbpress_installed() && is_bbpress() )
$view = 'page';

 do_action( 'pojo_setup_body_classes', $view, get_post_type(), '' );

  get_header();

 do_action( 'pojo_get_start_layout', $view, get_post_type(), '' );
   ?>

  <header>
            <?php if ( po_breadcrumbs_need_to_show() ) : ?>
                <?php pojo_breadcrumbs(); ?>
            <?php endif; ?>
            <?php if ( pojo_is_show_page_title() ) : ?>
                <div class="page-title">
                    <h1><?php the_title(); ?></h1>
                </div>
            <?php endif; ?>
        </header>
        <?php the_content(); ?>

 <?php

 global $_pojo_parent_id, $custom_query;


   $_pojo_parent_id = get_the_ID();
   $pagination = atmb_get_field( 'po_pagination' );
   $display_type = po_get_display_type();

  $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
  $args = array ( 'post_type' => 'property', 'post_per_page' => 8, 'paged' => $paged );

  $custom_query = new WP_Query( $args ); 
 ?>
        <?php if ( $custom_query->have_posts() ) : ?>

            <?php do_action( 'pojo_before_content_loop', $display_type ); ?>
            <?php while ( $custom_query->have_posts() ) : $custom_query->the_post(); ?>
                <?php pojo_get_content_template_part( 'content', $display_type ); ?>

            <?php endwhile;
             ?>
            <?php do_action( 'pojo_after_content_loop', $display_type ); ?>
            <?php  if ( 'hide' !== $pagination ) : ?>
                <?php pojo_paginate( ); ?>
            <?php endif;  ?>
            <?php echo apply_filters( 'the_content', '' ); ?>

        <?php endif; ?>
    <?php endif; ?>
    <?php pojo_button_post_edit(); ?>
  • what is the full code of the function pojo_paginate( ) ? this function might not work with a custom query. – Michael Jan 15 at 17:55
1

If you go to the URL https://nadlancz.com/page/2/ you'll see that navigation works.

What you need to do to see the navigation links is add something like this to your page

<!-- Navigation -->
<?php
    $pagination = get_the_posts_pagination(array(
       'mid_size' => 2,
       'prev_text' => 'Previous',
       'next_text' => 'Next',
    ));

    if (defined('DOING_AJAX')) {
        $pagination = reformat_ajax_pagination($pagination);
    }

    echo $pagination;
?>
| improve this answer | |
0

The problem could be a number of things.

First of all, make sure you have more than 8 posts. If you do, then make sure you're pagination is working properly (numbered nav links to different pages should show up on page).

Some more information would be helpful to better answer you question. Maybe a screenshot of the rendered page?

| improve this answer | |
0

Thanks to all! I was needed to add parameter to pojo_paginate():

pojo_paginate( $custom_query )
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.