• Hi..

    I have problem with pagination in Home or Front Page. I set it as latest posts for 12 posts per page (customizr setting) but the pagination shows 404 page Not Found.

    I still can’t get it worked even after i read this : https://www.ads-software.com/support/topic/new-wp_query-vs-query_posts-in-customizr-loop?replies=8

    This is my code in function.php of my child theme :

    //setup hooks in the template_redirect action => once the main WordPress query is set
    add_action( 'template_redirect', 'hooks_setup' , 20 );
    function hooks_setup() {
        if (! is_home() ) //<= you can also use any conditional tag here
            return;
        add_action( '__before_loop'     , 'set_my_query' );
        add_action( '__after_loop'      , 'set_my_query', 100 );
    }
    function set_my_query() {
        global $wp_query, $wp_the_query;
        switch ( current_filter() ) {
        	case '__before_loop':
        	//replace the current query by a custom query
    	//Note : the initial query is stored in another global named $wp_the_query
    		    $wp_query = new WP_Query( array(
    		    	'paged'             => get_query_var('paged') ? get_query_var('paged') : 1,
    			'post_type'         => array('post','film','music'),
    			'post_status'       => 'publish',
    			//others parameters...
    		    ) );
        	break;
    
        	default:
        		//back to the initial WP query stored in $wp_the_query
        		$wp_query = $wp_the_query;
        	break;
        }
    }

    Any Help ?

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Still can't get it worked, paged the latest posts in home’ is closed to new replies.