implement only image of latest post in own site (2 posts)

  1. m.schalkx
    Posted 4 years ago #

    Hello guys, i'm new to wordpress and i'm trying to integrate it in my existing site.

    To do so i'm using the following code:

    $args = array( 'numberposts' => 1 );
    $lastposts = get_posts( $args );
    foreach($lastposts as $post) : setup_postdata($post); ?><?php the_content(); ?><?php endforeach; ?>

    This does the trick, but now i would like to only have posts of a particular categorie be shown. So i tried to add 'category' => 3 to the $args = array line. But if i do so, nothing shows up (and there are posts in this categorie). Any ideas why this is?

    Also, in this case, i would like to only have the image of the post be shown, so no title, date (i already removed <?php the_title(); ?> and <?php the_date(); ?> so that wont show up), but the permalink and excerpt arte still there and don't have their own <?php> tag in the code as seen above.. So can this be done?

    The site im talking about http://www.moschalkx.nl/index1.php

    Hope you guys can make something of it!

  2. vtxyzzy
    Posted 4 years ago #

    I think the parameter you want to use is 'cat' => 3.

Topic Closed

This topic has been closed to new replies.

About this Topic