How to get articles from Blog page and put it to other template

php-extension

#1

The code below works only for Blog template and snippets. Now my scenario is i want to display the articles in other template and snippet.

Can someone help me pls. Heres my controller

        return function($site, $pages, $page) {

    	$perpage  = $page->perpage()->int();
    	$articles = $page->children()
    	               ->visible()
    	               ->flip()
    	               ->paginate(($perpage >= 1)? $perpage : 9)->sortBy('date', 'desc', 'time', 'desc');

      return [
        'articles'   => $articles,
        'pagination' => $articles->pagination()
      ];
    		if(kirby()->request()->ajax()){
                    // in ajax request - this snippet will be returned by the server.. the site and page object should be redeclared in here...
                    // in ajax, the global objects are unknown
                    exit(snippet('blog', compact('pagination'), true));
                    
                } else {
                    return compact('pagination');
                }

#2

Replace $page with page('blog').


#3

that works, thanks again texnixe