PHP for WordPress -- Loops
Official documentation WP Loop (Please Read)
<?php
if ( have_posts() ) :
while ( have_posts() ) : the_post();
the_title( '<h2>', '</h2>' );
the_post_thumbnail();
the_excerpt();
endwhile;
else:
_e( 'Sorry, no posts matched your criteria.', 'textdomain' );
endif;
This was an example of the famous WP loop.
Below are noted for the PHP loops
---with the break, we go out from the loop
PHP for WordPress -- Functions
PHP for WordPress -- Functions
function add($var1, $var2) {
return $var1 + $var2;
}
$result1 = add(5, 3); //= 8
echo $result1;
Start with the word Function
Maybe accepts input (it can have defaults)
We invoke it from our site.