Php Wordpress store get_在变量中发布数据

Php Wordpress store get_在变量中发布数据,php,arrays,wordpress,variables,Php,Arrays,Wordpress,Variables,我有这个密码 global $post; $size = array(75,75); $args = array( 'numberposts' => 3, 'category' => 'Allgemein' ); $myposts = get_posts( $args ); foreach( $myposts as $post ) { setup_postdata($post); echo the_title();

我有这个密码

global $post;
    $size = array(75,75);
    $args = array( 'numberposts' => 3, 'category' => 'Allgemein' );
    $myposts = get_posts( $args );



    foreach( $myposts as $post ) {  setup_postdata($post); 

        echo the_title();
        echo "<br>";
        echo the_excerpt();
        echo "<br>";
        echo the_permalink(); 
        echo "<br>";
        echo get_the_post_thumbnail($post_id, $size);
        echo "<br>";


     };  

提前感谢,我非常感谢您提供的任何帮助。

将它们存储在阵列中,以便您可以广泛使用

$store_post_data = array();
foreach( $myposts as $post ) {  setup_postdata($post); 
        $store_post_data[get_the_ID()]['title'] = get_the_title();
        $store_post_data[get_the_ID()]['excerpt'] = get_the_excerpt();
        $store_post_data[get_the_ID()]['permalink'] = get_permalink();
        $store_post_data[get_the_ID()]['thumbnail'] = get_the_post_thumbnail($post->ID, $size);
};  
然后打印循环外部的数组

print_r($store_post_data);

为数组中的每个post生成计数器和pull值

$posts_info = array();
$counter = 0;

foreach( $myposts as $post ) {  setup_postdata($post); 

    $posts_info[$counter]['title'] = get_the_title($post->ID);
    $posts_info[$counter]['excerpt'] = get_the_excerpt($post->ID);
    $posts_info[$counter]['link'] = get_the_permalink($post->ID);
    $posts_info[$counter]['thumb'] = get_the_post_thumbnail($post->ID, $size);

    $counter++;
}; 

如何获取第一篇文章的标题^^
$posts_info = array();
$counter = 0;

foreach( $myposts as $post ) {  setup_postdata($post); 

    $posts_info[$counter]['title'] = get_the_title($post->ID);
    $posts_info[$counter]['excerpt'] = get_the_excerpt($post->ID);
    $posts_info[$counter]['link'] = get_the_permalink($post->ID);
    $posts_info[$counter]['thumb'] = get_the_post_thumbnail($post->ID, $size);

    $counter++;
};