Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 获取数组中的wordpress自定义post类型元盒值_Php_Custom Post Type_Wordpress - Fatal编程技术网

Php 获取数组中的wordpress自定义post类型元盒值

Php 获取数组中的wordpress自定义post类型元盒值,php,custom-post-type,wordpress,Php,Custom Post Type,Wordpress,我已经在wordpress主题中创建了“公文包”自定义帖子类型 <?php add_action( 'init', 'portfolio' ); function portfolio() { $labels = array( 'name' => _x('portfolio', 'post type general name'), 'singular_name' => _x('portfolio', 'post type

我已经在wordpress主题中创建了“公文包”自定义帖子类型

<?php
    add_action( 'init', 'portfolio' );
    function portfolio() {
      $labels = array(
        'name' => _x('portfolio', 'post type general name'),
        'singular_name' => _x('portfolio', 'post type singular name'),
        'add_new' => _x('Add New', 'Slide'),
        'add_new_item' => __('Add New slide'),
        'edit_item' => __('Edit project'),
        'new_item' => __('New project'),
        'view_item' => __('View project'),
        'search_items' => __('Search project'),
        'not_found' =>  __('No project Found'),
        'not_found_in_trash' => __('No project found in Trash'),
        'parent_item_colon' => ''
      );

    $supports = array( 'title','editor','thumbnail');

      register_post_type( 'portfolio', 
        array(
          'labels' => $labels,
          'public' => false,
          'publicly_queryable'          =>false,
          'show_ui'         =>true,
          'show_in_menu'        =>true,
          'query_var'           =>true,
          'rewrite'         =>false,
          'capability_type'             =>'post',
          'has_archive'         =>false,
          'hierarchical'        =>false,
          'menu_position'       =>15,
          'supports' => $supports
        )
      );
    }


    ?>

把这个写在一个循环中

<script>
var arr = new Array();
/*loop starts here*/
for(i=0;i<5;i++){

     arr.push('<?php echo get_post_meta($post->ID,'portfolio-url',true); ?>');

/*loop ends here*/
}
</script>

var arr=新数组();
/*循环从这里开始*/

对于(i=0;i将其写入循环中,其中

<script>
var arr = new Array();
/*loop starts here*/
for(i=0;i<5;i++){

     arr.push('<?php echo get_post_meta($post->ID,'portfolio-url',true); ?>');

/*loop ends here*/
}
</script>

var arr=新数组();
/*循环从这里开始*/
对于(i=0;i