• Resolved aakraak

    (@aakraak)


    Hello!

    I am making a static homepage and I want to display my posts in the static homepage. This is the code I am using.

    <!-- start content -->
    <div id="content">
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
    <div class="post" id="post-<?php the_ID(); ?>">
    
    <?php
     global $post;
     $myposts = get_posts('numberposts=1&category=1');
     foreach($myposts as $post) :
     ?>
    <h1 class="kop_home"><?php the_title(); ?></h1>
    
    <div class="entry">
    <?php the_content('Read the rest of this entry &raquo;'); ?>
    </div>
    
    <?php endforeach; ?>
    
    <?php endwhile; else: ?>
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    <?php endif; ?>
    
    			</div>
    
    <!-- end content -->

    I made two pages; one homepage and one blogpage. The post is visible on the homepage, but it is only the title that is show. There is no content! I do not know how to solve this!

    HelP!

Viewing 1 replies (of 1 total)
  • Thread Starter aakraak

    (@aakraak)

    Yess! I found the solution myself!

    Do the following.

    – Download this plugin nurelm-get-posts.0.2

    past this piece of code into your html:

    <?php
     $postslist = get_posts('numberposts=10&order=ASC&orderby=title');
     foreach ($postslist as $post) :
        setup_postdata($post);
     ?>
     <div>
     <?php the_date(); ?>
     <br />
     <?php the_title(); ?>
     <?php the_excerpt(); ?>
     </div>
     <?php endforeach; ?>

    custimized as desired. My piece of code
    looks like this, because I want the h1 to look like I want to and I want the whole content to show up instead of just the_excerpt!

    <?php
     $postslist = get_posts('numberposts=1&order=ASC&orderby=title');
     foreach ($postslist as $post) :
        setup_postdata($post);
     ?>
         <div>
             <h1 class="kop_home"><?php the_title(); ?> </h1>
             <?php the_content('Read the rest of this entry &raquo;'); ?>
         </div>
     <?php endforeach; ?>

    Hope this helps anyone!

Viewing 1 replies (of 1 total)
  • The topic ‘Display most recent posts on static homepage -no content’ is closed to new replies.