i have this code

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>";


     };  

how can i save the data for each post in different variables like this ?:

 $post9_title = $latesposts[8]->the_title();

Thanks in advance, i appreciate any help you can provide.

Read more here: WordPress store get_posts data in variables


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: