• 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
    /**
     * Default Page
    /*
    Template Name: property-page
    */
    if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
    global $_pojo_parent_id; ?>
    
    	<?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 ( post_password_required( $_pojo_parent_id ) ) : ?>
    			<?php echo get_the_password_form( $_pojo_parent_id ); ?>
    		<?php else : ?>
            
    			<?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(); ?>
    	
    
    <?php do_action( 'pojo_get_end_layout', $view, get_post_type(), '' );
    
    get_footer();
    ?>
    • This topic was modified 5 years, 10 months ago by Jan Dembowski.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Your custom query says to show only 8.
    You seem to be going at this backwards.
    1. If this is in the theme, the name of your file will be interpreted by the Template Hierarchy as the template to use for a Page with a slug of property.
    2. If this is in the theme: Since you have the page template comment at the top, this can be assigned to a Page. There is to point in checking for is_singular() or is_search() or is_404(). Those are based on the WordPress query, which you are ignoring for your loop.
    3. You check for password protected for the loop, but not for the content of the actual Page.

    It seems like you would be defining a set of custom post type templates, according to the hierarchy.

    Moderator bcworkz

    (@bcworkz)

    You’re getting only one page worth of posts because the paged query var is set for a singular page, which is always 1. Extract the requested page before the query parser gets a hold of it (from $_SERVER for example) and use that to set your query’s “paged” argument. Or figure out your own offsets from the requested page and pass “offset” instead of paged.

    • This reply was modified 5 years, 10 months ago by bcworkz.
    Thread Starter yehuditjosef

    (@yehuditjosef)

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

    pojo_paginate($custom_query )

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘WP Query for all posts’ is closed to new replies.