我在 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
)
);
}
?>
在其中成功添加了一个带有文本输入的元框,以获取投资组合图像的 URL。以这种方式添加了 5 个帖子,其中在元框中具有投资组合图像 url。该值的输出是<?php echo get_post_meta($post->ID,'portfolio-url',true); ?>
我创建了 5 个投资组合,每个投资组合都有 url。如何获取数组中所有 url 的值,以便我可以将 jquery 中的这些值用作变量?
var _portfolioImage = [url1,url2,url3,url4,url5];