• Resolved nicholas_benoit

    (@nicholas_benoit)


    First let me say after trying multiple ajax loading plugins, I like how this one works the most. However, I can only get it to work on my index.php, taxonomy pages, archives, etc. For the life of me, I can’t get this to work if it’s on a template that’s calling a custom post type. Without the plugin, I can get pagination working no problem – I just can’t get it to replace the pagination with the load more button.

    My loop on this page:

    <?php
    					$args = array ('post_type' => 'portfolio', 'paged'=>$paged);
    					$wp_query = new WP_Query ( $args );
    				?>
    
    				<?php if ( have_posts() ) : ?>
    
    					<div class="grid_size col-xs-6 col-sm-3"></div>
    
    					<?php /* Start the Loop */ ?>
    						<?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>
    							<?php get_template_part( 'template-parts/content', 'project_list' ); ?>
    						<?php endwhile; ?>
    
    				<?php
    					the_posts_pagination( array(
    						'prev_text'          => __( 'Previous page', 'benoit_2015' ),
    						'next_text'          => __( 'Next page', 'benoit_2015' ),
    						'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'benoit_2015' ) . ' </span>',
    					) );
    				?>
    
    				<?php else : ?>
    
    					<?php get_template_part( 'template-parts/content', 'none' ); ?>
    
    				<?php endif; ?>
    
    				<?php wp_reset_postdata(); ?>

    Any help would be appreciated.

    -Nick

    https://wordpress.org/plugins/malinky-ajax-pagination/

Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter nicholas_benoit

    (@nicholas_benoit)

    yikes! I didn’t mean for my code to be formatted so wild. let me see if I can clean that up:

    `
    <?php $args = array (‘post_type’ => ‘portfolio’, ‘paged’=>$paged);
    $wp_query = new WP_Query ( $args );
    ?>

    <?php if ( have_posts() ) : ?>
    <div class=”grid_size col-xs-6 col-sm-3″></div>
    <?php /* Start the Loop */ ?>
    <?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>
    <?php get_template_part( ‘template-parts/content’, ‘project_list’ ); ?>
    <?php endwhile; ?>

    <?php
    the_posts_pagination( array(
    ‘prev_text’ => __( ‘Previous page’, ‘benoit_2015’ ),
    ‘next_text’ => __( ‘Next page’, ‘benoit_2015’ ),
    ‘before_page_number’ => ‘<span class=”meta-nav screen-reader-text”>’ . __( ‘Page’, ‘benoit_2015’ ) . ‘ </span>’,
    ) );
    ?>

    <?php else : ?>

    <?php get_template_part( ‘template-parts/content’, ‘none’ ); ?>

    <?php endif; ?>

    <?php wp_reset_postdata(); ?>’

    I have the same issu, doesnt work on custom post types, how can I resolve problem?

    Thanks in advance…

    Plugin Author craigramsay

    (@malinkymedia)

    Could you both send me a link to your websites if they are live so I can take a look?

    Thanks

    Plugin Author craigramsay

    (@malinkymedia)

    Also have you set up a second page of settings specifically for the custom post type as they normally require a different posts selector in the settings?

    Thread Starter nicholas_benoit

    (@nicholas_benoit)

    Unfortunately my site is not live at the moment. But yes, there is a separate template file being used for this post type, and the loop on that page looks like:

    <?php $args = array ('post_type' => 'portfolio', 'paged' => $paged);
    					$wp_query = new WP_Query ( $args );
    				?>
    
    				<?php if ( have_posts() ) : ?>
    
    					<?php /* Start the Loop */ ?>
    					<?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>
    						<?php
    
    							$termsArray = get_the_terms($post->ID, "project_type");
    							$termsString = "";
    								foreach ($termsArray as $term) {
    									$termsString .= $term->slug.' ';
    								}
    
    							get_template_part( 'template-parts/content', 'project_list' );
    						?>
    
    					<?php endwhile; ?>

    I can confirm that pagination is working on this template without the plugin. It’s just that the plugin is not replacing the pagination on this template with the “Load More Posts” link the way that it does on index.php and my taxonomies page.

    Thanks,

    -Nick

    I also cannot get this to work?

    There are no instructions in the plugin, or on this site detailing how exactly to implement this? Unless I’m missing something…

    which parameters are you using and what is you website?

    Plugin Author craigramsay

    (@malinkymedia)

    Resolved

    mpseitenweise

    (@mpseitenweise)

    Could you post the answer, please?

    Plugin Author craigramsay

    (@malinkymedia)

    There’s no answer. This has been inactive for 4 months and without a demo site or the full template to look at it’s impossible to know what selectors should be use.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Can't get this to work on a custom post type’ is closed to new replies.