• Resolved Angela

    (@angelazou)


    I would like to get 4 posts, in ascending order, sorted by their title as part of a page, using the get_posts function. I’m currently using the following code in HTML editing mode, enclosed between <codes> tag (pulled from this codex page), but it doesn’t seem to work.

    <?php
    $args = array( 'numberposts' => 4, 'order'=> 'ASC', 'orderby' => 'title' );
    $postslist = get_posts( $args );
    foreach ($postslist as $post) :  setup_postdata($post);
    ?>
    	<div class="front-posts">
                    <a href="<?php the_permalink(); ?>"><span class="title"><?php the_title(); ?> </span></a> |
    		<span class="date"><?php the_date(); ?> </span>
    		<br /><br />
    		<span class="exerpt"><?php the_excerpt(); ?> </span>
    	</div>
    <?php endforeach; ?>

    All the code between the first pair of PHP tags are shown as plaintext. I have no idea why as all other pairs are working very well, none of them are exposed as plaintext. Any ideas why it’s this way?

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘get_posts’ is closed to new replies.