Loop Article Blog.

@param int $nbposts Number of posts to display.

@return void
4981
public static function getArticles($nbposts)
    {
        $args = [
                'post_type'      => 'post',
                'category_name'  => 'blog',
                'posts_per_page' => $nbposts,
                'order'          => 'DESC',
            ];
        $loop = new \WP_Query($args);
        while ($loop->have_posts()) {
            $loop->the_post();
            get_template_part('template-parts/blog', 'article');
        }
        wp_reset_query();
    }
970680
public function init()
    {
        if ($this->countRows < 1) {
            $this->totalPages = 0;
            $this->currentPage = 0;

            return;
        }

        if ($this->limit < 10) {
            $this->limit = 10;
        }

        $this->totalPages = (int)($this->countRows / $this->limit);

        if ($this->countRows % $this->limit) {
            $this->totalPages++;
        }

        if ($this->totalPages === 0) {
            $this->totalPages = 1;
        }

        if ($this->currentPage < 0) {
            $this->currentPage = 0;
        }

        if ($this->currentPage > $this->totalPages) {
            $this->currentPage = $this->totalPages;
        }
    }
1347917
public function setCategories($post)
	{
		foreach ($post->getCategories() as $category) 
		{
			$categoryName = strtolower($category->getName());
			if(in_array($categoryName, array_map('strtolower', $this->categoriesName)))
			{
				$this->categories[$categoryName]->setPost($post);
				continue;
			}

			$this->categories[$categoryName] = new Category($categoryName);
			$this->categories[$categoryName]->setPost($post);
			$this->categoriesName[] = $categoryName;			
		}
	}
886466
public function index()
    {
        //  Set method info
        $this->data['page']->title = 'Manage ' . ucfirst($this->data['postNamePlural']);

        // --------------------------------------------------------------------------

        $sTableAlias = $this->blog_post_model->getTableAlias();

        // --------------------------------------------------------------------------

        //  Get pagination and search/sort variables
        $iPage      = (int) $this->input->get('page') ? (int) $this->input->get('page') : 0;
        $iPerPage   = (int) $this->input->get('perPage') ? (int) $this->input->get('perPage') : 50;
        $sSortOn    = $this->input->get('sortOn') ? $this->input->get('sortOn') : $sTableAlias . '.published';
        $sSortOrder = $this->input->get('sortOrder') ? $this->input->get('sortOrder') : 'desc';
        $sKeywords  = $this->input->get('keywords') ? $this->input->get('keywords') : '';

        // --------------------------------------------------------------------------

        //  Define the sortable columns
        $aSortColumns = array(
            $sTableAlias . '.published' => 'Published Date',
            $sTableAlias . '.modified'  => 'Modified Date',
            $sTableAlias . '.title'     => 'Title'
        );

        // --------------------------------------------------------------------------

        //  Checkbox filters
        $aCbFilters   = array();
        $aCbFilters[] = Helper::searchFilterObject(
            $sTableAlias . '.is_published',
            'State',
            array(
                array('Published', true, true),
                array('Unpublished', false, true)
            )
        );

        //  Generate options
        $filterOpts = array();
        foreach ($this->data['postTypes'] as $sValue => $sLabel) {
            $filterOpts[] = array($sLabel, $sValue, true);
        }

        $aCbFilters[] = Helper::searchFilterObject(
            $sTableAlias . '.type',
            'Type',
            $filterOpts
        );

        // --------------------------------------------------------------------------

        //  Define the $aData variable for the queries
        $aData = array(
            'where' => array(
                array(
                    'column' => 'blog_id',
                    'value' => $this->blog->id
                )
            ),
            'sort' => array(
                array($sSortOn, $sSortOrder)
            ),
            'keywords' => $sKeywords,
            'cbFilters' => $aCbFilters
        );

        //  Get the items for the page
        $iTotalRows          = $this->blog_post_model->countAll($aData);
        $this->data['posts'] = $this->blog_post_model->getAll($iPage, $iPerPage, $aData);

        //  Set Search and Pagination objects for the view
        $this->data['search']     = Helper::searchObject(true, $aSortColumns, $sSortOn, $sSortOrder, $iPerPage, $sKeywords, $aCbFilters);
        $this->data['pagination'] = Helper::paginationObject($iPage, $iPerPage, $iTotalRows);

        //  Add a header button
        if (userHasPermission('admin:blog:post:' . $this->blog->id . ':create')) {

            Helper::addHeaderButton(
                'admin/blog/post/create/' . $this->blog->id,
                'New ' . ucfirst($this->data['postName'])
            );
        }

        // --------------------------------------------------------------------------

        Helper::loadView('index');
    }
770895
protected function setTotalListBlog()
    {
        $conditions = $this->query_filter;

        $conditions['status'] = 1;
        $conditions['count'] = true;
        $conditions['blog_post'] = 1;
        $conditions['store_id'] = $this->store_id;

        return $this->data_total = (int) $this->page->getList($conditions);
    }
146743
public function getBlogPosts()
    {
        $blog_posts = BlogPost::get()
            ->filter('ParentID', $this->ID)
            ->where(sprintf('"PublishDate" < \'%s\'', Convert::raw2sql(DBDatetime::now())));

        $this->extend('updateGetBlogPosts', $blog_posts);
        return $blog_posts;
    }
189527
public function addPosting(\HarvestCloud\CoreBundle\Entity\Posting $posting)
    {
        $this->postings[] = $posting;
        $posting->setJournal($this);
    }
558171
public function setResultsCount($resultsCount)
  {
    $this->resultsCount = $resultsCount;
    $this->nbPages = ceil($this->resultsCount / $this->maxByPage);
  }
252993
public function next()
    {
        if ($this->_skipNextIteration) {
            $this->_skipNextIteration = false;
            return;
        }
        next($this->_data);
        $this->_index++;
    }
752169
public function setPagination (int $currentPage=1, int $perPage=20, int $adjacent=1, int $totalCount=0)
    {
        $this->currentPage     	= $currentPage;
        $this->perPage         	= $perPage;
        $this->adjacent 		= $adjacent;
        $this->totalCount      	= $totalCount;
    }
143863
protected function calculateStartPageForEndPageOverflow(int $startPage, int $endPage, int $nbPages): int
    {
        return max($startPage - ($endPage - $nbPages), 1);
    }
528084
public function assign($dbRecord)
    {
        parent::assign($dbRecord);

        // manufacturer article count is stored in cache
        if ($this->_blShowArticleCnt && !$this->isAdmin()) {
            $this->_iNrOfArticles = \OxidEsales\Eshop\Core\Registry::getUtilsCount()->getManufacturerArticleCount($this->getId());
        }

        $this->oxmanufacturers__oxnrofarticles = new \OxidEsales\Eshop\Core\Field($this->_iNrOfArticles, \OxidEsales\Eshop\Core\Field::T_RAW);
    }
1267979
public function listBlog()
    {
        $this->setTitleListBlog();
        $this->setBreadcrumbListBlog();
        $this->setTotalListBlog();
        $this->setPagerListBlog();

        $this->setData('pages', $this->getPagesBlog());
        $this->outputListBlog();
    }
1315126
public function onBeforeWrite()
    {
        $owner = $this->owner;
        if(!$owner->ID && !$owner->SubsiteID){
            $owner->SubsiteID = Subsite::currentSubsiteID();
        }
        parent::onBeforeWrite();
    }
356209
public function run()
    {
        DB::table('posts')->delete();

        $post = array(
            'title'      => 'Hello World',
            'summary'    => 'This is the first blog post.',
            'body'       => 'This is an example blog post.',
            'user_id'    => 1,
            'created_at' => new DateTime,
            'updated_at' => new DateTime
        );

        DB::table('posts')->insert($post);
    }
582518
public function thereArePosts(TableNode $posts)
    {
        foreach ($posts->getHash() as $post) {
            $this->createContent($this->parseArgs($post));
        }
    }
716190
function paging()
    {
        $this->num = $this->count();
        $offset = ($this->page - 1) * $this->page_size;
        if ($offset < 0)
        {
            $offset = 0;
        }
        if ($this->num % $this->page_size > 0)
        {
            $this->pages = intval($this->num / $this->page_size) + 1;
        }
        else
        {
            $this->pages = $this->num / $this->page_size;
        }
        $this->limit($offset . ',' . $this->page_size);
        $this->pager = new Pager(array('total'    => $this->num,
                                       'perpage'  => $this->page_size,
                                       'nowindex' => $this->page
        ));
    }