• Resolved dekraan

    (@dekraan)


    Hi there all, I know my question is very basic for wordpressusers with some experience, but I am not one of those.

    I have a ‘home-page’ and a ‘blog-page’. on settings/reading I put static page, making ‘home’ the front and ‘blog’ the postpage. My ‘home’ is a custom template-page.

    Now, how can I get the titles of all the blogs on ‘blog’ to appear in a vertical list on ‘home’? I know it has something to do with the ‘loop’, but I just can’t figure it out.

    I want to add this code in a <div> through page/edit page! Who knows how I can?

Viewing 6 replies - 1 through 6 (of 6 total)
  • <?php
    $args=array(
      'post_type' => 'post',
      '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 'List of Posts';
      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
      endwhile;
    }
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?>
    Thread Starter dekraan

    (@dekraan)

    Hello MichaelH, thanks for your very correct answer! It works brilliantly! Do you know of a way to display the published date in front of each post as well?

    And does your code show all posts, or just a specific number of latest posts?

    Is the echo necessary by the way, or can I just remove the words in between the ‘ and ‘ if I do not want a text there?

    That should show all posts. That echo statement is not necessary.

    An example of using template tag, the_time():

    <p><?php the_time('m.d.y') ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>

    Also see query_posts()

    Thread Starter dekraan

    (@dekraan)

    Thank you very much. An excellent solution! Now only one question remains. Pherhaps you know how to limit the number of posts? I assume it has something to do with ‘posts_per_page’?

    Yes, use posts_per_page to limits the posts to number you desire.

    Thread Starter dekraan

    (@dekraan)

    Thank you very much ?? this topic is closed and solved!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Basic help: how to show blogtitles on home?’ is closed to new replies.