DataSource/WpciQuery.php
public function addPostData(?callable $anotherElse = null, bool $withoutWp = false)
    {
        /** @var WpPost $post global post */
        $post = Core::get(WpPost::class);

        $queryObject = $this->wpQuery();

        $data = [];
        if ($queryObject->have_posts()) {
            $queryObject->the_post();
            $data['title'] = $this->wpProvider->getTheTitle();

            ob_start();
            $this->wpProvider->theContent();
            $data['content'] = ob_get_clean();

            $postData['excerpt'] = $post->post_excerpt;

            $data = array_merge($this->getAcfFromPage($post->ID), $data);
            if (!is_null($anotherElse)) {
                $anotherElse($data, $post);
            }
        }

        if (!$withoutWp) {
            ob_start();
            $this->wpProvider->wpHead();
            $data['wp-head'] = ob_get_clean();

            ob_start();
            $this->wpProvider->wpFooter();
            $data['wp-footer'] = ob_get_clean();
        }

        $queryObject->rewind_posts();
        $this->wpProvider->wpResetPostData();

        $this->mergeToTheData($data);
        return $this;
    }
public function addPostData(?callable $anotherElse = null, bool $withoutWp = false)
    {
        /** @var WpPost $post global post */
        $post = Core::get(WpPost::class);

        $queryObject = $this->wpQuery();

        $data = [];
        if ($queryObject->have_posts()) {
            $queryObject->the_post();
            $data['title'] = $this->wpProvider->getTheTitle();

            ob_start();
            $this->wpProvider->theContent();
            $data['content'] = ob_get_clean();

            $postData['excerpt'] = $post->post_excerpt;

            $data = array_merge($this->getAcfFromPage($post->ID), $data);
            if (!is_null($anotherElse)) {
                $anotherElse($data, $post);
            }
        }

        if (!$withoutWp) {
            ob_start();
            $this->wpProvider->wpHead();
            $data['wp-head'] = ob_get_clean();

            ob_start();
            $this->wpProvider->wpFooter();
            $data['wp-footer'] = ob_get_clean();
        }

        $queryObject->rewind_posts();
        $this->wpProvider->wpResetPostData();

        $this->mergeToTheData($data);
        return $this;
    }
public function addPostData ( ? callable $ anotherElse = null , bool $ withoutWp = false ) { /** @var WpPost $post global post */ $ post = Core :: get ( WpPost :: class ) ; $ queryObject = $ this -> wpQuery ( ) ; $ data = [ ] ; if ( $ queryObject -> have_posts ( ) ) { $ queryObject -> the_post ( ) ; $ data [ 'title' ] = $ this -> wpProvider -> getTheTitle ( ) ; ob_start ( ) ; $ this -> wpProvider -> theContent ( ) ; $ data [ 'content' ] = ob_get_clean ( ) ; $ postData [ 'excerpt' ] = $ post -> post_excerpt ; $ data = array_merge ( $ this -> getAcfFromPage ( $ post -> ID ) , $ data ) ; if ( ! is_null ( $ anotherElse ) ) { $ anotherElse ( $ data , $ post ) ; } } if ( ! $ withoutWp ) { ob_start ( ) ; $ this -> wpProvider -> wpHead ( ) ; $ data [ 'wp-head' ] = ob_get_clean ( ) ; ob_start ( ) ; $ this -> wpProvider -> wpFooter ( ) ; $ data [ 'wp-footer' ] = ob_get_clean ( ) ; } $ queryObject -> rewind_posts ( ) ; $ this -> wpProvider -> wpResetPostData ( ) ; $ this -> mergeToTheData ( $ data ) ; return $ this ; }
Add to result current post data
@param callable|null $anotherElse
@param bool $withoutWp
@return WpciQuery
@throws \Exception
@throws \Error
Add to result current post data