public function load($id, $load_terms = true)
    {
        $info = (is_object($id)) ? $id : get_post($id);
        if (!is_object($info)) {
            return false;
        }

        // Handle how WordPress converts special chars out of the DB
        // b/c even when you pass 'raw' as the 3rd partam to get_post,
        // WordPress will still encode the values.
        if (isset($info->post_title) && preg_match('/[&]{1,}/', $info->post_title)) {
            $info->post_title = html_entity_decode($info->post_title);
        }

        $this->_info = (array) $info;

        // meta
        $meta = get_post_meta($this->_info[self::ID]);
        if (Arr::iterable($meta)) {
            foreach ($meta as $k => $v) {
                $this->set($k, current($v));
            }
        }

        // terms
        if (!$load_terms) {
            return true;
        }
        $this->loadTerms();

        return true;
    }
public function load($id, $load_terms = true)
    {
        $info = (is_object($id)) ? $id : get_post($id);
        if (!is_object($info)) {
            return false;
        }

        // Handle how WordPress converts special chars out of the DB
        // b/c even when you pass 'raw' as the 3rd partam to get_post,
        // WordPress will still encode the values.
        if (isset($info->post_title) && preg_match('/[&]{1,}/', $info->post_title)) {
            $info->post_title = html_entity_decode($info->post_title);
        }

        $this->_info = (array) $info;

        // meta
        $meta = get_post_meta($this->_info[self::ID]);
        if (Arr::iterable($meta)) {
            foreach ($meta as $k => $v) {
                $this->set($k, current($v));
            }
        }

        // terms
        if (!$load_terms) {
            return true;
        }
        $this->loadTerms();

        return true;
    }
public function load ( $ id , $ load_terms = true ) { $ info = ( is_object ( $ id ) ) ? $ id : get_post ( $ id ) ; if ( ! is_object ( $ info ) ) { return false ; } // Handle how WordPress converts special chars out of the DB // b/c even when you pass 'raw' as the 3rd partam to get_post, // WordPress will still encode the values. if ( isset ( $ info -> post_title ) && preg_match ( '/[&]{1,}/' , $ info -> post_title ) ) { $ info -> post_title = html_entity_decode ( $ info -> post_title ) ; } $ this -> _info = ( array ) $ info ; // meta $ meta = get_post_meta ( $ this -> _info [ self :: ID ] ) ; if ( Arr :: iterable ( $ meta ) ) { foreach ( $ meta as $ k => $ v ) { $ this -> set ( $ k , current ( $ v ) ) ; } } // terms if ( ! $ load_terms ) { return true ; } $ this -> loadTerms ( ) ; return true ; }
Load a post by ID
@param mixed $id String or integer as post ID, or post object
@param bool $load_terms
@return bool
Load a post by ID