WordPress.org

Support

Support » How-To and Troubleshooting » Custom Post Ajax pagination

Custom Post Ajax pagination

  • I have a custom page that displays custom post types using the following

    —-template file———

    <h1 class="topic entry-title open">Discussions</h1>
    <div>
    <?php
    $page = (get_query_var('page')) ? get_query_var('page') : $page;
    $args= array('post_type'=>'discussions','posts_per_page'=>1,'order'=>'DESC','paged'=>max(1,$page));
    query_posts($args); while ( have_posts() ) : the_post(); ?>
    <?php get_template_part( 'content', 'link-discussions' ); // default content ?>
    <?php endwhile;echo get_previous_posts_link(); echo get_next_posts_link(); wp_reset_query(); ?>
    </div>

    the ajax function simply
    ——— functions file—————-

    function ajax_get_template_part() {
    	global $page;
    	$page = isset($_REQUEST['page'])? $_GET['page'] : 1;
    	//Handle request then generate response using WP_Ajax_Respons
    	// get the submitted parameters
    	$slug = isset($_POST['slug'])? $_POST['slug'] : 'discussions';
    	get_template_part('content',$slug);
    	die();
    }

    ————— custom url page link ———-
    I’m also trying to load content via custom pagination ajax with a url

    url/?paged=1#post_type

    My problem seems to be that I’m either not “catching” the ?paged=# or the query_posts doesn’t seem to have the paging incorrect

    Why am I not getting the page? and how can I get it through get_query_var(‘page’)?

Viewing 1 replies (of 1 total)
  • shame! the so called “wp experts” they don’t answer qns in wp website these days …so sorry mate!

Viewing 1 replies (of 1 total)
  • The topic ‘Custom Post Ajax pagination’ is closed to new replies.
Skip to toolbar