SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Zealot
    Join Date
    Nov 2007
    Posts
    164
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Noob question about Wordpress/Feeds or MySQL/PHP

    I have a Wordpress blog. I'd like to pull the first 5 posts from the blog, display the title, date, and say the first couple sentences of the post, and a read more link on the home page. When the 6th post is added for example, it knocks one off automatically so I don't have to always check to see if that content on the home page is fresh.

    Is this something that a feed can be setup to handle or will I have to look at pulling this content from the Wordpress database using something like PHP?

    Thanks for any help.

  2. #2
    SitePoint Enthusiast SuperNovaArcade's Avatar
    Join Date
    Oct 2008
    Location
    United States
    Posts
    95
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you feeding to a different website, or just directly on the open page of your blog?

  3. #3
    SitePoint Zealot
    Join Date
    Nov 2007
    Posts
    164
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Same website... I just want to pull that info from the blog to my home page.

  4. #4
    Is Still Alive silver trophybronze trophy RetroNetro's Avatar
    Join Date
    Jul 2003
    Location
    Texas
    Posts
    6,883
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    This can all be accomplished with the options in the dashboard and a few small edits to your index.php file.

    In the dashboard settings > reading you can choose how many posts will display on the front page (as well as archive pages)

    As for the index.php file (I am assuming this is what your theme has)

    Change the_content to the_excerpt, then make sure to add a excerpt to each post, you can just copy the first bit of the post and paste it into the excerpt area.

    Hope this helps.

    PS
    You may also want to make the same change to the archive.php file if you want it to only display the excerpt.

  5. #5
    Is Still Alive silver trophybronze trophy RetroNetro's Avatar
    Join Date
    Jul 2003
    Location
    Texas
    Posts
    6,883
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by matius View Post
    Same website... I just want to pull that info from the blog to my home page.
    Oh, I see your homepage is not part of the WP?

    If so, ignore what I said above and...

    Add this to the home page file (at the top)
    Code PHP:
    <?php
    define('WP_USE_THEMES', false);
    require('./wp_directory/wp-blog-header.php');
    query_posts('showposts=6');
    ?>
    Make sure to change the path (3rd line) to the folder/directory you have WP installed in.

    Then this goes where you want the posts to appear:
    Code PHP:
    <?php while (have_posts()): the_post(); ?>
    <hx><?php the_title(); ?></hx>
    <?php the_time('F jS, Y') ?>
    <?php the_excerpt(); ?>
    <p><a href="<?php the_permalink(); ?>">Read more...</a></p>
    <?php endwhile; ?>
    Change the <hx></hx> to whatever level heading is appropiate for your site.

    Hope it helps.

  6. #6
    SitePoint Zealot
    Join Date
    Nov 2007
    Posts
    164
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's going to help a ton! Thank you... appreciate your help.

  7. #7
    SitePoint Addict bamaboy's Avatar
    Join Date
    Apr 2009
    Location
    Internet
    Posts
    224
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a lot BPartch
    I was dealing thing, I was about to make a thread, but found one already. (my luck)

    Great thanks from my part.
    Hymoo.com - Create Revolution - Help Us Spread The Word!
    Latest Wallpapers


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •