• Resolved lapd

    (@lapd)


    Hi!

    I am working on a site and got to a dead end. I have alot of pages, while i use posts only for news.

    Now i want to display 2 thing on my front page. First would be my latest post (news) and the second would be the latest page that was published (my articles).

    Can i do this with some kind of plugin or can some one help me with the code for this?

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • MichaelH

    (@michaelh)

    <?php
    $types[0] = 'post';
    $types[1] = 'page';
    
    foreach ($types as $type) {
      $args=array(
        'orderby' => 'date',
        'order' => 'DESC',
        'post_type' => $type,
        'post_status' => 'publish',
        'posts_per_page' => 1,
        'caller_get_posts'=> 1
        );
      $my_query = null;
      $my_query = new WP_Query($args);
      if( $my_query->have_posts() ) {
        echo 'Latest ' . $type ;
        while ($my_query->have_posts()) : $my_query->the_post(); ?>
          <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
          <?php
          the_content();
        endwhile;
      } //if ($my_query)
    } // foreach
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?>
    Thread Starter lapd

    (@lapd)

    Damn that worked like a charm 😀

    Thank you very much!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Show last post and last page on front screen’ is closed to new replies.