1

currently I have installed wordpress v4.7.2 and created a child-theme by twentyfifteen

I have create a custom post type.

enter image description here

now when browse the localhost, I got as should be the list, and the pagination is not working :( :

for example for page2 points

localhost/page/2/

--

when accessing as localhost/works

the pagination working fine enter image description here

the code Im using also on archive and template files, is the following :

// Previous/next page navigation.
the_posts_pagination( array(
    'prev_text'          => __( 'Previous page', 'twentyfifteen' ),
    'next_text'          => __( 'Next page', 'twentyfifteen' ),
    'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'twentyfifteen' ) . ' </span>',
) );

<!--when WORKS is as default page homepage-->
works-template.php

<!--when access it via localhost/works-->
archive-works.php

the only different is that on works-template.php, calling the query_posts()

<?php
$posts_per_page = get_query_var('posts_per_page');
$paged          = ( get_query_var('page') ) ? get_query_var('page') : 1;
$args           = array('post_type'     => 'works','posts_per_page'=> $posts_per_page ,'post_status'   => 'publish' ,'orderby'       => 'menu_order','order'         => 'ASC','paged'         =>$paged);


query_posts( $args );

// Start the Loop.
while ( have_posts() ) : the_post();

any suggestion?

0

the solution is dont use #static pages# and merge to functions.php

Merge to functions.php the following :

//http://justintadlock.com/archives/2010/02/02/showing-custom-post-types-on-your-home-blog-page
add_filter( 'pre_get_posts', 'my_get_posts' );

function my_get_posts( $query ) {

    if ( is_home() && $query->is_main_query() )
        $query->set( 'post_type', array( 'works' ) );
    //else 
        //$query->set( 'post_type', ' page' );//$query->set( 'post_type', array( 'page', 'post' ) );

    return $query;
}

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.