protected function getWPPosts($options = [], $value = 'ID')
    {
        // Build contents
        $contents = [];
        $contents[-1] = Translate::t('wordpress.choose.post', [], 'wordpressfield');

        // Build options
        $args = array_merge([
            'post_type' => 'post',
            'post_status' => 'publish'
        ], $options);

        // Build request
        $posts_obj = wp_get_recent_posts($args, OBJECT);

        // Iterate on posts
        if (!empty($posts_obj)) {
            foreach ($posts_obj as $pos) {
                // For Wordpress version < 3.0
                if (empty($pos->ID)) {
                    continue;
                }

                // Check value
                $item = !empty($value) && isset($pos->$value) ? $pos->$value : $pos->ID;

                // Get the id and the name
                $contents[$pos->post_type][$item] = $pos->post_title;
            }
        }

        // Return all values in a well formatted way
        return $contents;
    }
protected function getWPPosts($options = [], $value = 'ID')
    {
        // Build contents
        $contents = [];
        $contents[-1] = Translate::t('wordpress.choose.post', [], 'wordpressfield');

        // Build options
        $args = array_merge([
            'post_type' => 'post',
            'post_status' => 'publish'
        ], $options);

        // Build request
        $posts_obj = wp_get_recent_posts($args, OBJECT);

        // Iterate on posts
        if (!empty($posts_obj)) {
            foreach ($posts_obj as $pos) {
                // For Wordpress version < 3.0
                if (empty($pos->ID)) {
                    continue;
                }

                // Check value
                $item = !empty($value) && isset($pos->$value) ? $pos->$value : $pos->ID;

                // Get the id and the name
                $contents[$pos->post_type][$item] = $pos->post_title;
            }
        }

        // Return all values in a well formatted way
        return $contents;
    }
protected function getWPPosts ( $ options = [ ] , $ value = 'ID' ) { // Build contents $ contents = [ ] ; $ contents [ - 1 ] = Translate :: t ( 'wordpress.choose.post' , [ ] , 'wordpressfield' ) ; // Build options $ args = array_merge ( [ 'post_type' => 'post' , 'post_status' => 'publish' ] , $ options ) ; // Build request $ posts_obj = wp_get_recent_posts ( $ args , OBJECT ) ; // Iterate on posts if ( ! empty ( $ posts_obj ) ) { foreach ( $ posts_obj as $ pos ) { // For Wordpress version < 3.0 if ( empty ( $ pos -> ID ) ) { continue ; } // Check value $ item = ! empty ( $ value ) && isset ( $ pos -> $ value ) ? $ pos -> $ value : $ pos -> ID ; // Get the id and the name $ contents [ $ pos -> post_type ] [ $ item ] = $ pos -> post_title ; } } // Return all values in a well formatted way return $ contents ; }
Get WordPress Posts registered.

@uses wp_get_recent_posts()

@param   array  $options     Define options if needed
@param   string $value       Define the value of each select options
@return  array  $wpcontents  Array of WordPress items
Get WordPress Posts registered .