Answer the question
In order to leave comments, you need to log in
How does wordpress know what a function is passing when it doesn't have a parameter?
The code shows that there is a foreach loop, inside it there is the_title () function, and yet, they have no parameters. How does he understand that for example it is necessary to display three records?
$args = array( 'posts_per_page' => 3 );
$lastposts = get_posts( $args );
foreach( $lastposts as $post ){ setup_postdata($post);
?>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php
the_content();
}
wp_reset_postdata();
Answer the question
In order to leave comments, you need to log in
this part of the code knows about 3 records
$args = array( 'posts_per_page' => 3 );
$lastposts = get_posts( $args );
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question