• Hi,
    I’m just curious about something that maybe has a obvious answer but I cannot find it.

    Why do you use global $post; with get_posts( );, like in the example bellow. Is it mandatory?

    <?php
    global $post;
    $args = array( 'numberposts' => 5, 'offset'=> 1, 'category' => 1 );
    $myposts = get_posts( $args );
    foreach( $myposts as $post ) :	setup_postdata($post); ?>
    	<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endforeach; ?>

    Thank you,
    Sacher

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘global $post and get_posts( )’ is closed to new replies.